[wasm] Fix bug with empty input to Wasm.instantiateModuleFromAsm()

R=ahaas@chromium.org,bradnelson@chromium.org
BUG=chromium:605488
LOG=Y

Review-Url: https://codereview.chromium.org/1940243002
Cr-Commit-Position: refs/heads/master@{#35974}
This commit is contained in:
titzer 2016-05-03 04:14:01 -07:00 committed by Commit bot
parent 18c380c396
commit 98c2312995
2 changed files with 17 additions and 0 deletions

View File

@ -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());

View File

@ -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);
}