Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Unified Diff: src/wasm/wasm-js.cc

Issue 2514983002: [wasm] Throw a RangeError if Wasm memory could not be allocated. (Closed)
Patch Set: Fixing nits Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/wasm/regression-666741.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-js.cc
diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc
index b95ab9a20f59544562c83e4040cf6d8654b9a5a2..4d395b1f08e8ed8504a259ebe7e88f49b10d6762 100644
--- a/src/wasm/wasm-js.cc
+++ b/src/wasm/wasm-js.cc
@@ -335,7 +335,7 @@ void WebAssemblyMemory(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
HandleScope scope(isolate);
ErrorThrower thrower(reinterpret_cast<i::Isolate*>(isolate),
- "WebAssembly.Module()");
+ "WebAssembly.Memory()");
if (args.Length() < 1 || !args[0]->IsObject()) {
thrower.TypeError("Argument 0 must be a memory descriptor");
return;
@@ -368,7 +368,10 @@ void WebAssemblyMemory(const v8::FunctionCallbackInfo<v8::Value>& args) {
static_cast<size_t>(initial);
i::Handle<i::JSArrayBuffer> buffer =
i::wasm::NewArrayBuffer(i_isolate, size, i::FLAG_wasm_guard_pages);
-
+ if (buffer.is_null()) {
+ thrower.RangeError("could not allocate memory");
+ return;
+ }
i::Handle<i::JSObject> memory_obj = i::WasmMemoryObject::New(
i_isolate, buffer, has_maximum.FromJust() ? maximum : -1);
args.GetReturnValue().Set(Utils::ToLocal(memory_obj));
« no previous file with comments | « no previous file | test/mjsunit/regress/wasm/regression-666741.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698