[ubsan] Fix overflow in AdjustAmountOfExternalAllocatedMemory

Similar issue as crbug.com/933103, so the fix follows the same
pattern too.

No regression test, because it will OOM anyway.

Bug: chromium:957015
Change-Id: Ic5b67d84aa1c44609e6c96485974af9ecab2ed0e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1585854
Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61101}
This commit is contained in:
Jakob Kummerow 2019-04-26 18:06:38 +02:00 committed by Commit Bot
parent 4995c85f28
commit 4349e32d4c

View File

@ -10881,7 +10881,8 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
*external_memory = amount;
int64_t allocation_diff_since_last_mc =
*external_memory - *external_memory_at_last_mc;
static_cast<int64_t>(static_cast<uint64_t>(*external_memory) -
static_cast<uint64_t>(*external_memory_at_last_mc));
// Only check memory pressure and potentially trigger GC if the amount of
// external memory increased.
if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {