Commit 39e455db authored by rossberg's avatar rossberg Committed by Commit bot

[wasm] Catch attempt to export non-existent memory

R=titzer@chromium.org
BUG=v8:5840

Review-Url: https://codereview.chromium.org/2633153002
Cr-Commit-Position: refs/heads/master@{#42384}
parent 38088853
...@@ -457,7 +457,11 @@ class ModuleDecoder : public Decoder { ...@@ -457,7 +457,11 @@ class ModuleDecoder : public Decoder {
} }
case kExternalMemory: { case kExternalMemory: {
uint32_t index = consume_u32v("memory index"); uint32_t index = consume_u32v("memory index");
if (index != 0) error("invalid memory index != 0"); // TODO(titzer): This should become more regular
// once we support multiple memories.
if (!module->has_memory || index != 0) {
error("invalid memory index != 0");
}
module->mem_export = true; module->mem_export = true;
break; break;
} }
......
...@@ -241,3 +241,9 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88))); ...@@ -241,3 +241,9 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88)));
assertThrows(() => new WebAssembly.Instance(module, {"":{memory:memory}}), WebAssembly.LinkError); assertThrows(() => new WebAssembly.Instance(module, {"":{memory:memory}}), WebAssembly.LinkError);
})(); })();
(function TestNoMemoryToExport() {
let builder = new WasmModuleBuilder();
builder.exportMemoryAs('memory');
assertThrows(() => builder.instantiate(), WebAssembly.CompileError);
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment