mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-04-05 04:06:08 +00:00
LibWasm: Properly read blocktypes
This works for now, but is technically still not spec compliant. Right now, we're (potentially) missing one bit when reading function indices. See the relevant issue: #24462.
This commit is contained in:
@@ -254,10 +254,12 @@ ParseResult<BlockType> BlockType::parse(Stream& stream)
|
||||
ReconsumableStream new_stream { stream };
|
||||
new_stream.unread({ &kind, 1 });
|
||||
|
||||
auto index_value_or_error = stream.read_value<LEB128<ssize_t>>();
|
||||
// FIXME: should be an i33. Right now, we're missing a potential last bit at
|
||||
// the end. See https://webassembly.github.io/spec/core/binary/instructions.html#binary-blocktype
|
||||
auto index_value_or_error = new_stream.read_value<LEB128<i32>>();
|
||||
if (index_value_or_error.is_error())
|
||||
return with_eof_check(stream, ParseError::ExpectedIndex);
|
||||
ssize_t index_value = index_value_or_error.release_value();
|
||||
i32 index_value = index_value_or_error.release_value();
|
||||
|
||||
if (index_value < 0) {
|
||||
dbgln("Invalid type index {}", index_value);
|
||||
|
||||
Reference in New Issue
Block a user