diff options
author | Changqing Jing <changqing.jing@bmw.com> | 2024-07-13 00:20:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-12 09:20:09 -0700 |
commit | 5d999f051238cb249a3bc80f23f68d2a55c01e96 (patch) | |
tree | 71b93e373ac1b0c04171d844d3d9bae40a62d83f | |
parent | adc4c9f3c296e3adfe31596b195e5e7f50dc9bd9 (diff) | |
download | wabt-5d999f051238cb249a3bc80f23f68d2a55c01e96.tar.gz wabt-5d999f051238cb249a3bc80f23f68d2a55c01e96.tar.bz2 wabt-5d999f051238cb249a3bc80f23f68d2a55c01e96.zip |
Fix parsing of malformed element section in text format (#2439)
-rw-r--r-- | src/wast-parser.cc | 2 | ||||
-rw-r--r-- | test/parse/module/bad-element-followed-by-illegal-expression.txt | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/wast-parser.cc b/src/wast-parser.cc index 236840ec..f950512f 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -874,7 +874,7 @@ bool WastParser::ParseElemExprOpt(ExprList* out_elem_expr) { } EXPECT(Rpar); } else { - if (ParseExpr(&exprs) != Result::Ok) { + if (!IsExpr(PeekPair()) || ParseExpr(&exprs) != Result::Ok) { return false; } } diff --git a/test/parse/module/bad-element-followed-by-illegal-expression.txt b/test/parse/module/bad-element-followed-by-illegal-expression.txt new file mode 100644 index 00000000..5243aedc --- /dev/null +++ b/test/parse/module/bad-element-followed-by-illegal-expression.txt @@ -0,0 +1,9 @@ +;;; TOOL: wat2wasm +;;; ARGS: --enable-gc +;;; ERROR: 1 +( elem f64 ( ) ) +(;; STDERR ;;; +out/test/parse/module/bad-element-followed-by-illegal-expression.txt:4:12: error: unexpected token (, expected ). +( elem f64 ( ) ) + ^ +;;; STDERR ;;) |