diff options
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 9f7a2af12..e6584972e 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -339,8 +339,19 @@ SExpressionWasmBuilder::SExpressionWasmBuilder(Module& wasm, Index i = 1; if (module[i]->dollared()) { wasm.name = module[i]->str(); + if (module.size() == 2) { + return; + } + i++; + } + + // spec tests have a `binary` keyword after the optional module name. Skip it + Name BINARY("binary"); + if (module[i]->isStr() && module[i]->str() == BINARY && + !module[i]->quoted()) { i++; } + if (i < module.size() && module[i]->isStr()) { // these s-expressions contain a binary module, actually std::vector<char> data; @@ -3290,6 +3301,10 @@ void SExpressionWasmBuilder::parseElem(Element& s, Table* table) { // Offset expression (offset (<expr>)) | (<expr>) auto& inner = *s[i++]; if (elementStartsWith(inner, OFFSET)) { + if (inner.size() > 2) { + throw ParseException( + "Invalid offset for an element segment.", s.line, s.col); + } segment->offset = parseExpression(inner[1]); } else { segment->offset = parseExpression(inner); |