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

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

Issue 2483053005: [wasm] Check data segments for zero-sized memory. (Closed)
Patch Set: Created 4 years, 1 month 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
« src/wasm/wasm-module.cc ('K') | « src/wasm/wasm-module.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-module.cc
diff --git a/test/cctest/wasm/test-run-wasm-module.cc b/test/cctest/wasm/test-run-wasm-module.cc
index 12633e92aeb76851d804cb97678e8b7e9769f01a..e9c46c96325cc4e0d90108c6624dff4d03ecbcde 100644
--- a/test/cctest/wasm/test-run-wasm-module.cc
+++ b/test/cctest/wasm/test-run-wasm-module.cc
@@ -810,3 +810,72 @@ TEST(InitDataAtTheUpperLimit) {
}
Cleanup();
}
+
+TEST(EmptyMemoryNonEmptyDataSegment) {
+ {
+ Isolate* isolate = CcTest::InitIsolateOnce();
+ HandleScope scope(isolate);
+ testing::SetupIsolateForWasmModule(isolate);
+
+ ErrorThrower thrower(isolate, "Run_WasmModule_InitDataAtTheUpperLimit");
+
+ const byte data[] = {
+ WASM_MODULE_HEADER, // --
+ kMemorySectionCode, // --
+ U32V_1(4), // section size
+ ENTRY_COUNT(1), // --
+ kResizableMaximumFlag, // --
+ 0, // initial size
+ 0, // maximum size
+ kDataSectionCode, // --
+ U32V_1(7), // section size
+ ENTRY_COUNT(1), // --
+ 0, // linear memory index
+ WASM_I32V_1(8), // destination offset
+ kExprEnd,
+ U32V_1(1), // source size
+ 'c' // data bytes
+ };
+
+ testing::CompileInstantiateWasmModuleForTesting(isolate, &thrower, data,
+ data + arraysize(data),
+ ModuleOrigin::kWasmOrigin);
+ // It should not be possible to instantiate this module.
+ CHECK(thrower.error());
+ }
+ Cleanup();
+}
+
+TEST(EmptyMemoryEmptyDataSegment) {
+ {
+ Isolate* isolate = CcTest::InitIsolateOnce();
+ HandleScope scope(isolate);
+ testing::SetupIsolateForWasmModule(isolate);
+
+ ErrorThrower thrower(isolate, "Run_WasmModule_InitDataAtTheUpperLimit");
+
+ const byte data[] = {
+ WASM_MODULE_HEADER, // --
+ kMemorySectionCode, // --
+ U32V_1(4), // section size
+ ENTRY_COUNT(1), // --
+ kResizableMaximumFlag, // --
+ 0, // initial size
+ 0, // maximum size
+ kDataSectionCode, // --
+ U32V_1(6), // section size
+ ENTRY_COUNT(1), // --
+ 0, // linear memory index
+ WASM_I32V_1(24), // destination offset
+ kExprEnd,
+ U32V_1(0), // source size
+ };
+
+ testing::CompileInstantiateWasmModuleForTesting(isolate, &thrower, data,
+ data + arraysize(data),
+ ModuleOrigin::kWasmOrigin);
+ // It should be possible to instantiate this module.
+ CHECK(!thrower.error());
+ }
+ Cleanup();
+}
« src/wasm/wasm-module.cc ('K') | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698