authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-04-19 19:59:14+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-04-19 19:59:14+02:00
log0286be127e4b9f74ddffcc241b947c7c5bb3dfce
treedb1a925176f8aff0125ff884a1099d89929cf279
parent3b6a4fe4cd0800b7078953d56156475f699751f1

Fix parseFormValueConstant

Signed/unsigned confusion made the code fail an assertion sometimes.

1 files changed, 4 insertions(+), 3 deletions(-)

std/debug.zig+4-3
...@@ -1440,7 +1440,7 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: var, size: usize) !...@@ -1440,7 +1440,7 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: var, size: usize) !
1440 return parseFormValueBlockLen(allocator, in_stream, block_len);1440 return parseFormValueBlockLen(allocator, in_stream, block_len);
1441}1441}
14421442
1443fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: bool, size: i32) !FormValue {1443fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: bool, comptime size: i32) !FormValue {
1444 return FormValue{1444 return FormValue{
1445 .Const = Constant{1445 .Const = Constant{
1446 .signed = signed,1446 .signed = signed,
...@@ -1449,8 +1449,9 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: boo...@@ -1449,8 +1449,9 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: boo
1449 2 => try in_stream.readIntLittle(u16),1449 2 => try in_stream.readIntLittle(u16),
1450 4 => try in_stream.readIntLittle(u32),1450 4 => try in_stream.readIntLittle(u32),
1451 8 => try in_stream.readIntLittle(u64),1451 8 => try in_stream.readIntLittle(u64),
1452 -1 => if (signed) try readULeb128(in_stream) else @intCast(u64, try readILeb128(in_stream)),1452 -1 => if (signed) @intCast(u64, try readILeb128(in_stream))
1453 else => unreachable,1453 else try readULeb128(in_stream),
1454 else => @compileError("Invalid size"),
1454 },1455 },
1455 },1456 },
1456 };1457 };