| 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();
|
| +}
|
|
|