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

Unified Diff: src/wasm/module-decoder.cc

Issue 2486973003: [wasm] Data section without memory causes a validation error (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
« no previous file with comments | « no previous file | src/wasm/wasm-module.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/module-decoder.cc
diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc
index 7028a463ed1ac2f22b84d756a07f863dfad9d9bb..8794fe64351ca17add7c44f5fa149f82796b0a82 100644
--- a/src/wasm/module-decoder.cc
+++ b/src/wasm/module-decoder.cc
@@ -327,6 +327,7 @@ class ModuleDecoder : public Decoder {
&module->min_mem_pages, &has_max,
WasmModule::kSpecMaxPages,
&module->max_mem_pages);
+ module->has_memory = true;
break;
}
case kExternalGlobal: {
@@ -411,6 +412,7 @@ class ModuleDecoder : public Decoder {
"memory", "pages", WasmModule::kV8MaxPages, &module->min_mem_pages,
&has_max, WasmModule::kSpecMaxPages, &module->max_mem_pages);
}
+ module->has_memory = true;
section_iter.advance();
}
@@ -594,6 +596,10 @@ class ModuleDecoder : public Decoder {
uint32_t data_segments_count = consume_u32v("data segments count");
module->data_segments.reserve(SafeReserve(data_segments_count));
for (uint32_t i = 0; ok() && i < data_segments_count; ++i) {
+ if (!module->has_memory) {
+ error("cannot load data without memory");
+ break;
+ }
TRACE("DecodeDataSegment[%d] module+%d\n", i,
static_cast<int>(pc_ - start_));
module->data_segments.push_back({
« no previous file with comments | « no previous file | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698