From 327245dfe20d45cf6782d8e4ca53fe1f86abd6a9 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 6 Feb 2019 12:57:29 -0800 Subject: throw an early error in s-expr-parsing makeBlock, if not inside a function (#1894) Fixes #1893 --- src/wasm/wasm-s-parser.cpp | 1 + 1 file changed, 1 insertion(+) (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 09cc044bf..d7b3824a9 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -786,6 +786,7 @@ Expression* SExpressionWasmBuilder::makeSetGlobal(Element& s) { Expression* SExpressionWasmBuilder::makeBlock(Element& s) { + if (!currFunction) throw ParseException("block is unallowed outside of functions"); // special-case Block, because Block nesting (in their first element) can be incredibly deep auto curr = allocator.alloc(); auto* sp = &s; -- cgit v1.2.3