From eceb0fb6ac097e262bf74dcdb686cfc5d4c55188 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Tue, 18 Jun 2024 18:35:30 -0700 Subject: Check malformed mutability on imported globals (#6679) And re-enable the globals.wast spec test, which checks this. --- src/wasm/wasm-binary.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/wasm/wasm-binary.cpp') diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 01b3602eb..cd1ca7dfd 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2591,6 +2591,9 @@ void WasmBinaryReader::readImports() { Name name(std::string("gimport$") + std::to_string(globalCounter++)); auto type = getConcreteType(); auto mutable_ = getU32LEB(); + if (mutable_ & ~1) { + throwError("Global mutability must be 0 or 1"); + } auto curr = builder.makeGlobal(name, type, -- cgit v1.2.3