Skip to content

Commit 8cdddcd

Browse files
ofrobotsMylesBorins
authored andcommitted
deps: cherry-pick ca0f9573 from V8 upstream
Original commit message: Trigger OOM crash if no memory returned in v8::ArrayBuffer::New and v… …8::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} PR-URL: #11940 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent d0868ff commit 8cdddcd

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 5
1212
#define V8_MINOR_VERSION 1
1313
#define V8_BUILD_NUMBER 281
14-
#define V8_PATCH_LEVEL 98
14+
#define V8_PATCH_LEVEL 99
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/api.cc

+11-3
Original file line numberDiff line numberDiff line change
@@ -6763,7 +6763,11 @@ Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
67636763
ENTER_V8(i_isolate);
67646764
i::Handle<i::JSArrayBuffer> obj =
67656765
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
6766-
i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length);
6766+
// TODO(jbroman): It may be useful in the future to provide a MaybeLocal
6767+
// version that throws an exception or otherwise does not crash.
6768+
if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length)) {
6769+
i::FatalProcessOutOfMemory("v8::ArrayBuffer::New");
6770+
}
67676771
return Utils::ToLocal(obj);
67686772
}
67696773

@@ -6959,8 +6963,12 @@ Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate,
69596963
ENTER_V8(i_isolate);
69606964
i::Handle<i::JSArrayBuffer> obj =
69616965
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared);
6962-
i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true,
6963-
i::SharedFlag::kShared);
6966+
// TODO(jborman): It may be useful in the future to provide a MaybeLocal
6967+
// version that throws an exception or otherwise does not crash.
6968+
if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true,
6969+
i::SharedFlag::kShared)) {
6970+
i::FatalProcessOutOfMemory("v8::SharedArrayBuffer::New");
6971+
}
69646972
return Utils::ToLocalShared(obj);
69656973
}
69666974

0 commit comments

Comments
 (0)