Index: src/wasm/wasm-interpreter.cc |
diff --git a/src/wasm/wasm-interpreter.cc b/src/wasm/wasm-interpreter.cc |
index 2ac681eff293dbb1a640ebb16bf6c6e1347323a6..8064bf2765c71c483c743092aa638fb4075e58ee 100644 |
--- a/src/wasm/wasm-interpreter.cc |
+++ b/src/wasm/wasm-interpreter.cc |
@@ -1419,7 +1419,16 @@ class ThreadImpl : public WasmInterpreter::Thread { |
if (target == nullptr) { |
return DoTrap(kTrapFuncInvalid, pc); |
} else if (target->function->sig_index != operand.index) { |
- return DoTrap(kTrapFuncSigMismatch, pc); |
+ // If not an exact match, we have to do a canonical check. |
+ // TODO(titzer): make this faster with some kind of caching? |
+ const WasmIndirectFunctionTable* table = |
+ &module()->function_tables[0]; |
+ int function_key = table->map.Find(target->function->sig); |
+ if (function_key < 0 || |
+ (function_key != |
+ table->map.Find(module()->signatures[operand.index]))) { |
+ return DoTrap(kTrapFuncSigMismatch, pc); |
+ } |
} |
DoCall(target, &pc, pc + 1 + operand.length, &limit); |