Use PartitionAllocZeroFill in FX_SafeAlloc().
Avoid a manual memset().
BUG=pdfium:1171
Change-Id: I4f7708d8ad75ca7fa697f69a24fa0de55286b5fa
Reviewed-on: https://pdfium-review.googlesource.com/c/44075
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/fx_memory.h b/core/fxcrt/fx_memory.h
index 5596bce..5ad66e7 100644
--- a/core/fxcrt/fx_memory.h
+++ b/core/fxcrt/fx_memory.h
@@ -43,12 +43,11 @@
if (!total.IsValid())
return nullptr;
- void* result = pdfium::base::PartitionAllocGenericFlags(
- gGeneralPartitionAllocator.root(), pdfium::base::PartitionAllocReturnNull,
- total.ValueOrDie(), "GeneralPartition");
- if (result)
- memset(result, 0, total.ValueOrDie());
- return result;
+ constexpr int kFlags = pdfium::base::PartitionAllocReturnNull |
+ pdfium::base::PartitionAllocZeroFill;
+ return pdfium::base::PartitionAllocGenericFlags(
+ gGeneralPartitionAllocator.root(), kFlags, total.ValueOrDie(),
+ "GeneralPartition");
}
inline void* FX_SafeRealloc(void* ptr, size_t num_members, size_t member_size) {