summaryrefslogtreecommitdiff
path: root/third_party/base
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-11-07 18:54:51 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-07 18:54:51 +0000
commitc9653fb272dd2d006a2725c42b5a36ffafb099a7 (patch)
tree11d97e0892c56a5c351b1e37fab3f0051d01c8e1 /third_party/base
parent0a9b0a15133370657a2f3e13f062028c17a3dc0b (diff)
downloadpdfium-c9653fb272dd2d006a2725c42b5a36ffafb099a7.tar.xz
Fix PartitionAlloc cookies for small in-place reallocs.
This ports the non-test portion of Chromium commit r514411 to PDFium. BUG=chromium:781473 Change-Id: Iab203edf3cb49a491aca5e524815a15e74f47581 Reviewed-on: https://pdfium-review.googlesource.com/17990 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'third_party/base')
-rw-r--r--third_party/base/allocator/partition_allocator/partition_alloc.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/third_party/base/allocator/partition_allocator/partition_alloc.cc b/third_party/base/allocator/partition_allocator/partition_alloc.cc
index a33d7f1d13..ff366b861f 100644
--- a/third_party/base/allocator/partition_allocator/partition_alloc.cc
+++ b/third_party/base/allocator/partition_allocator/partition_alloc.cc
@@ -1065,8 +1065,10 @@ void* PartitionReallocGeneric(PartitionRootGeneric* root,
// after updating statistics (and cookies, if present).
PartitionPageSetRawSize(page, PartitionCookieSizeAdjustAdd(new_size));
#if DCHECK_IS_ON()
- // Write a new trailing cookie.
- PartitionCookieWriteValue(static_cast<char*>(ptr) + new_size);
+ // Write a new trailing cookie when it is possible to keep track of
+ // |new_size| via the raw size pointer.
+ if (PartitionPageGetRawSizePtr(page))
+ PartitionCookieWriteValue(static_cast<char*>(ptr) + new_size);
#endif
return ptr;
}