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

Unified Diff: test/cctest/wasm/test-run-wasm-interpreter.cc

Issue 2344853002: [wasm] Do proper bounds checking in the wasm interpreter for grow memory. (Closed)
Patch Set: Created 4 years, 3 months 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 | « src/wasm/wasm-interpreter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/test-run-wasm-interpreter.cc
diff --git a/test/cctest/wasm/test-run-wasm-interpreter.cc b/test/cctest/wasm/test-run-wasm-interpreter.cc
index ff5f57ea432f2cb9a53c7a7535551fceb5605a66..db5bb2a786c6891fc7f890fb48c3ca5222d8faa7 100644
--- a/test/cctest/wasm/test-run-wasm-interpreter.cc
+++ b/test/cctest/wasm/test-run-wasm-interpreter.cc
@@ -306,6 +306,25 @@ TEST(GrowMemoryPreservesData) {
WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V(index))));
CHECK_EQ(value, r.Call(1));
}
+
+TEST(GrowMemoryInvalidSize) {
+ {
+ // Grow memory by an invalid amount without initial memory.
+ TestingModule module(kExecuteInterpreted);
+ WasmRunner<int32_t> r(&module, MachineType::Uint32());
+ BUILD(r, WASM_BLOCK(WASM_GROW_MEMORY(WASM_GET_LOCAL(0))));
+ CHECK_EQ(-1, r.Call(1048575));
+ }
+ {
+ // Grow memory by an invalid amount without initial memory.
+ TestingModule module(kExecuteInterpreted);
+ WasmRunner<int32_t> r(&module, MachineType::Uint32());
+ module.AddMemory(WasmModule::kPageSize);
+ BUILD(r, WASM_BLOCK(WASM_GROW_MEMORY(WASM_GET_LOCAL(0))));
+ CHECK_EQ(-1, r.Call(1048575));
+ }
+}
+
} // namespace wasm
} // namespace internal
} // namespace v8
« no previous file with comments | « src/wasm/wasm-interpreter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698