From 4f33690ae906622adcf06f2c4b1f3436da4c3448 Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Sat, 27 May 2017 10:38:18 -0700 Subject: handle the wrong number of functions being provided in binary format --- src/wasm/wasm-binary.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/wasm/wasm-binary.cpp') diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index c4bc66f76..54b9a5bda 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1684,6 +1684,14 @@ void WasmBinaryBuilder::processFunctions() { for (auto& func : functions) { wasm.addFunction(func); } + + // we should have seen all the functions + // we assume this later down in fact, when we read wasm.functions[index], + // as index was validated vs functionTypes.size() + if (wasm.functions.size() != functionTypes.size()) { + throw ParseException("did not see the right number of functions"); + } + // now that we have names for each function, apply things if (startIndex != static_cast(-1)) { -- cgit v1.2.3