Skip to content

Commit 3d9ec15

Browse files
authored
Improve lexing of invalid annotations (#2150)
This had been crashing even with annotations disabled. Adds a regression test. This was missed in #2001 when updating the lexer to match the updated spec (WebAssembly/spec#1499). Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53935
1 parent 6a11a5b commit 3d9ec15

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/wast-lexer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Token WastLexer::GetToken() {
7070
}
7171
return BareToken(TokenType::Eof);
7272
} else if (MatchString("(@")) {
73-
ReadReservedChars();
73+
GetIdToken();
7474
// offset=2 to skip the "(@" prefix
7575
return TextToken(TokenType::LparAnn, 2);
7676
} else {

test/regress/bad-annotation.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
;;; TOOL: wat2wasm
2+
;;; ERROR: 1
3+
(@"annotation
4+
5+
(;; STDERR ;;;
6+
out/test/regress/bad-annotation.txt:3:1: error: annotations not enabled: "annotation
7+
(@"annotation
8+
^^^^^^^^^^^^^
9+
out/test/regress/bad-annotation.txt:3:1: error: unexpected token "Invalid", expected a module field or a module.
10+
(@"annotation
11+
^^^^^^^^^^^^^
12+
;;; STDERR ;;)

0 commit comments

Comments
 (0)