From 50dc1c3c19b82af797c79b5aa694b3ac7f0114bb Mon Sep 17 00:00:00 2001 From: Diego <96022404+dzfrias@users.noreply.github.com> Date: Sun, 2 Jun 2024 16:31:25 -0700 Subject: [PATCH] LibWasm: Fix memarg multi-memory reading The extension bit for the memory index present in memargs is at position 6, but we previously checked position 5, which caused a few spec issues. --- Userland/Libraries/LibWasm/Parser/Parser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWasm/Parser/Parser.cpp b/Userland/Libraries/LibWasm/Parser/Parser.cpp index 742c90bdae3..4c32c386798 100644 --- a/Userland/Libraries/LibWasm/Parser/Parser.cpp +++ b/Userland/Libraries/LibWasm/Parser/Parser.cpp @@ -388,8 +388,8 @@ ParseResult> Instruction::parse(Stream& stream, InstructionP // Proposal "multi-memory", if bit 6 of alignment is set, then a memory index follows the alignment. size_t memory_index = 0; - if ((align & 0x20) != 0) { - align &= ~0x20; + if ((align & 0x40) != 0) { + align &= ~0x40; auto memory_index_or_error = stream.read_value>(); if (memory_index_or_error.is_error()) return with_eof_check(stream, ParseError::InvalidInput);