From eafdf9dc78e858b6d823771a2add8302564d93ef Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 3 Jun 2016 13:52:26 -0700 Subject: trap on invalid call_indirects with bad arguments when no type provided --- src/wasm-interpreter.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/wasm-interpreter.h') diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 0ee2aff78..82ead1d8f 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -359,6 +359,10 @@ private: LiteralList arguments; Flow flow = generateArguments(curr->operands, arguments); if (flow.breaking()) return flow; + if (func->params.size() != arguments.size()) trap("callIndirect: bad # of arguments"); + for (size_t i = 0; i < func->getNumLocals(); i++) { + if (func->params[i] != arguments[i].type) trap("callIndirect: bad argument type"); + } return instance.callFunctionInternal(name, arguments); } -- cgit v1.2.3