From 13a9d521bce7780032b33c51725876e69f297bde Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 3 Feb 2022 10:18:14 -0800 Subject: Fix an assertion in the validator on call_ref heaptypes (#4496) We can only call getHeapType if it is indeed a function type. Otherwise we should show the error and move on. --- src/wasm/wasm-validator.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/wasm/wasm-validator.cpp') diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 1ad1380c9..65fcc7a9d 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2324,10 +2324,11 @@ void FunctionValidator::visitCallRef(CallRef* curr) { curr, "call_ref requires typed-function-references to be enabled"); if (curr->target->type != Type::unreachable) { - shouldBeTrue(curr->target->type.isFunction(), - curr, - "call_ref target must be a function reference"); - validateCallParamsAndResult(curr, curr->target->type.getHeapType()); + if (shouldBeTrue(curr->target->type.isFunction(), + curr, + "call_ref target must be a function reference")) { + validateCallParamsAndResult(curr, curr->target->type.getHeapType()); + } } } -- cgit v1.2.3