From 1a5dffbba9c247786ccfe4dd0a510d4e0f156595 Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Mon, 29 May 2017 17:01:02 -0700 Subject: host op parsing error handling --- src/wasm/wasm-s-parser.cpp | 9 +++++++++ 1 file changed, 9 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 af77d75b6..b2ee2a2f4 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -955,6 +955,15 @@ Expression* SExpressionWasmBuilder::makeHost(Element& s, HostOp op) { } else { parseCallOperands(s, 1, s.size(), ret); } + if (ret->op == HostOp::GrowMemory) { + if (ret->operands.size() != 1) { + throw ParseException("grow_memory needs one operand"); + } + } else { + if (ret->operands.size() != 0) { + throw ParseException("host needs zero operands"); + } + } ret->finalize(); return ret; } -- cgit v1.2.3