diff options
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r-- | src/wasm-binary.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h index dcbe7d6db..eef315fda 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -845,7 +845,7 @@ public: } void writeFunctionTableDeclaration() { - if (!wasm->table.exists) return; // or is imported!! + if (!wasm->table.exists || wasm->table.imported) return; if (debug) std::cerr << "== writeFunctionTableDeclaration" << std::endl; auto start = startSection(BinaryConsts::Section::Table); o << U32LEB(1); // Declare 1 table. @@ -1639,6 +1639,7 @@ public: WASM_UNUSED(elementType); if (elementType != BinaryConsts::ElementType::AnyFunc) throw ParseException("Imported table type is not AnyFunc"); wasm.table.exists = true; + wasm.table.imported = true; getResizableLimits(wasm.table.initial, &wasm.table.max); break; } @@ -1892,6 +1893,7 @@ public: if (debug) std::cerr << "== readFunctionTableDeclaration" << std::endl; auto numTables = getU32LEB(); if (numTables != 1) throw ParseException("Only 1 table definition allowed in MVP"); + if (wasm.table.exists) throw ParseException("Table cannot be both imported and defined"); wasm.table.exists = true; auto elemType = getU32LEB(); if (elemType != BinaryConsts::ElementType::AnyFunc) throw ParseException("ElementType must be AnyFunc in MVP"); |