diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc index 833c399025..0992031e45 100644 --- a/src/wasm/wasm-js.cc +++ b/src/wasm/wasm-js.cc @@ -134,6 +134,11 @@ v8::internal::wasm::WasmModuleIndex* TranslateAsmModule( return nullptr; } + if (info->scope()->declarations()->length() == 0) { + thrower->Error("Asm.js validation failed: no declarations in scope"); + return nullptr; + } + info->set_literal( info->scope()->declarations()->at(0)->AsFunctionDeclaration()->fun()); diff --git a/test/mjsunit/regress/regress-605488.js b/test/mjsunit/regress/regress-605488.js new file mode 100644 index 0000000000..03e6a38e28 --- /dev/null +++ b/test/mjsunit/regress/regress-605488.js @@ -0,0 +1,12 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-wasm + +try { + Wasm.instantiateModuleFromAsm(""); + assertTrue(false); +} catch (e) { + print("Caught: " + e); +}