Skip to content

Commit ca31986

Browse files
ofrobotsitaloacasas
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}
1 parent dcac2d8 commit ca31986

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 5
1313
#define V8_BUILD_NUMBER 372
14-
#define V8_PATCH_LEVEL 41
14+
#define V8_PATCH_LEVEL 42
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
@@ -7277,7 +7277,11 @@ Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
72777277
ENTER_V8(i_isolate);
72787278
i::Handle<i::JSArrayBuffer> obj =
72797279
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
7280-
i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length);
7280+
// TODO(jbroman): It may be useful in the future to provide a MaybeLocal
7281+
// version that throws an exception or otherwise does not crash.
7282+
if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length)) {
7283+
i::FatalProcessOutOfMemory("v8::ArrayBuffer::New");
7284+
}
72817285
return Utils::ToLocal(obj);
72827286
}
72837287

@@ -7467,8 +7471,12 @@ Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate,
74677471
ENTER_V8(i_isolate);
74687472
i::Handle<i::JSArrayBuffer> obj =
74697473
i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared);
7470-
i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true,
7471-
i::SharedFlag::kShared);
7474+
// TODO(jborman): It may be useful in the future to provide a MaybeLocal
7475+
// version that throws an exception or otherwise does not crash.
7476+
if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true,
7477+
i::SharedFlag::kShared)) {
7478+
i::FatalProcessOutOfMemory("v8::SharedArrayBuffer::New");
7479+
}
74727480
return Utils::ToLocalShared(obj);
74737481
}
74747482

0 commit comments

Comments
 (0)