From 91e936276fd2be8ed7168d665140706cd4a20707 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 16 Oct 2018 20:45:23 +0000 Subject: 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 Commit-Queue: Lei Zhang --- core/fxcrt/fx_memory.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/fxcrt/fx_memory.h b/core/fxcrt/fx_memory.h index 5596bceabe..5ad66e710d 100644 --- a/core/fxcrt/fx_memory.h +++ b/core/fxcrt/fx_memory.h @@ -43,12 +43,11 @@ inline void* FX_SafeAlloc(size_t num_members, size_t member_size) { 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) { -- cgit v1.2.3