From 62d83d5fcad015ce52f0f3122eab9df1c629cafb Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 16 Dec 2021 09:39:17 -0800 Subject: Add binary format parse checking for ref.as input type (#4389) If that type is not valid then we cannot even create and finalize the node, which means we'd hit an assertion inside finalize(), before we reach the validator. Fixes #4383 --- src/wasm/wasm-binary.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index bf29f948b..d8a3c2f74 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -6898,6 +6898,9 @@ void WasmBinaryBuilder::visitRefAs(RefAs* curr, uint8_t code) { WASM_UNREACHABLE("invalid code for ref.as_*"); } curr->value = popNonVoidExpression(); + if (!curr->value->type.isRef() && curr->value->type != Type::unreachable) { + throwError("bad input type for ref.as: " + curr->value->type.toString()); + } curr->finalize(); } -- cgit v1.2.3