From f36058e50d0aadcdeeb68716e69af83c75a51cff Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 4 Nov 2015 18:07:09 -0800 Subject: fix load/store traps --- src/wasm-shell.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/wasm-shell.cpp') diff --git a/src/wasm-shell.cpp b/src/wasm-shell.cpp index 4d2d3b560..4d16a8d3b 100644 --- a/src/wasm-shell.cpp +++ b/src/wasm-shell.cpp @@ -58,7 +58,7 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { size_t addr = ptr.geti32(); int64_t full = addr; full += load->offset; - if (full + load->bytes >= memorySize) trap(); + if (full + load->bytes > memorySize) trap(); addr = full; switch (load->type) { case i32: { @@ -81,7 +81,7 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { size_t addr = ptr.geti32(); int64_t full = addr; full += store->offset; - if (full + store->bytes >= memorySize) trap(); + if (full + store->bytes > memorySize) trap(); switch (store->type) { case i32: { switch (store->bytes) { @@ -146,6 +146,7 @@ int main(int argc, char **argv) { Element& curr = *root[i]; IString id = curr[0]->str(); if (id == MODULE) break; + std::cerr << curr << '\n'; Element& invoke = *curr[1]; assert(invoke[0]->str() == INVOKE); IString name = invoke[1]->str(); -- cgit v1.2.3