Commit bf52ff62 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[api] Guard for large values in AdjustAmountOfExternalAllocatedMemory

Guard for extremely large and small values passed to
Isolate::AdjustAmountOfExternalAllocatedMemory from the embedder.

Bug: chromium:1147372
Change-Id: Ib1470bdf2dd16cbc6e61dd1bca97fa5a66f04c77
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2543925
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71241}
parent 6d10bcb7
......@@ -8734,6 +8734,14 @@ size_t Isolate::NumberOfPhantomHandleResetsSinceLastCall() {
int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
int64_t change_in_bytes) {
// Try to check for unreasonably large or small values from the embedder.
const int64_t kMaxReasonableBytes = int64_t(1) << 60;
const int64_t kMinReasonableBytes = -kMaxReasonableBytes;
STATIC_ASSERT(kMaxReasonableBytes >= i::JSArrayBuffer::kMaxByteLength);
CHECK(kMinReasonableBytes <= change_in_bytes &&
change_in_bytes < kMaxReasonableBytes);
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
int64_t amount = i_isolate->heap()->update_external_memory(change_in_bytes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment