Skip to content

Commit ab3fdf5

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 54f5258 commit ab3fdf5

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 4
1212
#define V8_MINOR_VERSION 5
1313
#define V8_BUILD_NUMBER 103
14-
#define V8_PATCH_LEVEL 46
14+
#define V8_PATCH_LEVEL 47
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
@@ -6580,7 +6580,11 @@ Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
65806580
ENTER_V8(i_isolate);
65816581
i::Handle<i::JSArrayBuffer> obj =
65826582
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
6583-
i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length);
6583+
// TODO(jbroman): It may be useful in the future to provide a MaybeLocal
6584+
// version that throws an exception or otherwise does not crash.
6585+
if (!i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length)) {
6586+
i::FatalProcessOutOfMemory("v8::ArrayBuffer::New");
6587+
}
65846588
return Utils::ToLocal(obj);
65856589
}
65866590

@@ -6775,8 +6779,12 @@ Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate,
67756779
ENTER_V8(i_isolate);
67766780
i::Handle<i::JSArrayBuffer> obj =
67776781
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared);
6778-
i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length, true,
6779-
i::SharedFlag::kShared);
6782+
// TODO(jborman): It may be useful in the future to provide a MaybeLocal
6783+
// version that throws an exception or otherwise does not crash.
6784+
if (!i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length, true,
6785+
i::SharedFlag::kShared)) {
6786+
i::FatalProcessOutOfMemory("v8::SharedArrayBuffer::New");
6787+
}
67806788
return Utils::ToLocalShared(obj);
67816789
}
67826790

0 commit comments

Comments
 (0)