From 9c6b8e0f626ade30cee113294019edbdbf29dd36 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 18 May 2017 10:47:23 -0700 Subject: Validate finalization (#1014) * validate that types are properly finalized, when in pass-debug mode (BINARYEN_PASS_DEBUG env var): check after each pass is run that the type of each node is equal to the proper type (when finalizing it, i.e., fully recomputing the type). * fix many fuzz bugs found by that. * in particular, fix dce bugs with type changes not being fully updated during code removal. add a new TypeUpdater helper class that lets a pass update types efficiently, by the helper tracking deps between blocks and branches etc., and updating/propagating type changes only as necessary. --- src/wasm/wasm-s-parser.cpp | 2 ++ 1 file changed, 2 insertions(+) (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 f9e3912f7..9b053d5b8 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -185,9 +185,11 @@ Element* SExpressionParser::parseString() { input++; std::string str; while (1) { + if (input[0] == 0) throw ParseException("unterminated string", line, start - lineStart); if (input[0] == '"') break; if (input[0] == '\\') { str += input[0]; + if (input[1] == 0) throw ParseException("unterminated string escape", line, start - lineStart); str += input[1]; input += 2; continue; -- cgit v1.2.3