From 98ec53359b8e61e717440f280d3fcc101fe140bb Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 16 May 2018 19:19:22 +0000 Subject: Add support for PartionRealloc to return nullptr Currently the PartitionRealloc code path will only exit, with no option to return nullptr on failure, unlike PartitionAlloc code path. This CL refactors the realloc code path to be similar to alloc code path, following the upstream patch: https://chromium-review.googlesource.com/c/chromium/src/+/1044971 This also changes the version of realloc exposed to third party C libs to have the nullptr behaviour, like the exposed version of alloc. This CL is a redo of https://pdfium-review.googlesource.com/c/pdfium/+/31990 BUG=chromium:783022 Change-Id: Ib1b659079585dfd0423d683b8a2c7b6758a22a01 Reviewed-on: https://pdfium-review.googlesource.com/32613 Commit-Queue: Ryan Harrison Reviewed-by: Tom Sepez Reviewed-by: Chris Palmer --- core/fxcrt/fx_memory.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/fxcrt/fx_memory.h') diff --git a/core/fxcrt/fx_memory.h b/core/fxcrt/fx_memory.h index f7e6d67520..707e084211 100644 --- a/core/fxcrt/fx_memory.h +++ b/core/fxcrt/fx_memory.h @@ -57,9 +57,9 @@ inline void* FX_SafeRealloc(void* ptr, size_t num_members, size_t member_size) { if (!size.IsValid()) return nullptr; - return pdfium::base::PartitionReallocGeneric( - gGeneralPartitionAllocator.root(), ptr, size.ValueOrDie(), - "GeneralPartition"); + return pdfium::base::PartitionReallocGenericFlags( + gGeneralPartitionAllocator.root(), pdfium::base::PartitionAllocReturnNull, + ptr, size.ValueOrDie(), "GeneralPartition"); } inline void* FX_AllocOrDie(size_t num_members, size_t member_size) { -- cgit v1.2.3