Commit ca0f9573 authored by jbroman's avatar jbroman Committed by Commit bot

Trigger OOM crash if no memory returned in v8::ArrayBuffer::New and v8::SharedArrayBuffer::New.

This API does not allow reporting failure, but we should crash rather than have
the caller get an ArrayBuffer that isn't properly set up.

BUG=chromium:681843

Review-Url: https://codereview.chromium.org/2641953002
Cr-Commit-Position: refs/heads/master@{#42511}
parent 5e30385d
......@@ -7575,7 +7575,11 @@ Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
i::Handle<i::JSArrayBuffer> obj =
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length);
// TODO(jbroman): It may be useful in the future to provide a MaybeLocal
// version that throws an exception or otherwise does not crash.
if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length)) {
i::FatalProcessOutOfMemory("v8::ArrayBuffer::New");
}
return Utils::ToLocal(obj);
}
......@@ -7765,8 +7769,12 @@ Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate,
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
i::Handle<i::JSArrayBuffer> obj =
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared);
i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true,
i::SharedFlag::kShared);
// TODO(jbroman): It may be useful in the future to provide a MaybeLocal
// version that throws an exception or otherwise does not crash.
if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true,
i::SharedFlag::kShared)) {
i::FatalProcessOutOfMemory("v8::SharedArrayBuffer::New");
}
return Utils::ToLocalShared(obj);
}
......
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