From a3157c8c6960541ba0a621680aadea7c9092bb03 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 14 Oct 2024 17:58:48 -0600 Subject: [PATCH] LibWasm: Reject indirect calls to external function references This fixes a test in the WebAssembly spec test suite that was added in https://github.com/WebAssembly/spec/commit/924c1f816d30c760bd4b66a9cf8d8f83f7f9ac2c --- Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp index a727998ba90..b970ddacbd1 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp @@ -2109,8 +2109,8 @@ VALIDATE_INSTRUCTION(call_indirect) TRY(validate(args.type)); auto& table = m_context.tables[args.table.value()]; - if (!table.element_type().is_reference()) - return Errors::invalid("table element type for call.indirect"sv, "a reference type"sv, table.element_type()); + if (table.element_type().kind() != ValueType::FunctionReference) + return Errors::invalid("table element type for call.indirect"sv, "a function reference"sv, table.element_type()); auto& type = m_context.types[args.type.value()];