summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-16 20:45:23 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-16 20:45:23 +0000
commit91e936276fd2be8ed7168d665140706cd4a20707 (patch)
tree38f2238ed4a08cedaf4a5c80d32c697b4956930c /core/fxcrt
parentae0a9e13025e63093508d02044987038e5a26f37 (diff)
downloadpdfium-91e936276fd2be8ed7168d665140706cd4a20707.tar.xz
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>
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_memory.h11
1 files 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) {