From 7d453930f1b211baf324b1c010924d3709ff12ba Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Mon, 1 Mar 2021 10:30:00 +0900 Subject: Allow empty body within catch block (#3630) Previously we assumed catch body's size should be at least 3: `catch` keyword, event name, and body. But catch's body can be empty when the event's type is none. This PR fixes the bug and allows empty catch bodies to be parsed correctly. Fixes #3629. --- src/wasm/wasm-s-parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wasm/wasm-s-parser.cpp') diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index edf8ec6f0..3874bd2c0 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -2237,7 +2237,7 @@ Expression* SExpressionWasmBuilder::makeTry(Element& s) { while (i < s.size() && elementStartsWith(*s[i], "catch")) { Element& inner = *s[i++]; - if (inner.size() < 3) { + if (inner.size() < 2) { throw ParseException("invalid catch block", inner.line, inner.col); } Name event = getEventName(*inner[1]); -- cgit v1.2.3