fix: panic on decode of a large negative integer

This commit is contained in:
CJ van den Berg 2026-03-12 19:27:48 +01:00
parent 13f8a698e4
commit d7c87d0562
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -367,7 +367,9 @@ fn decodePInt(iter: *[]const u8, minor: u5) error{ TooShort, InvalidPIntType }!u
}
fn decodeNInt(iter: *[]const u8, minor: u5) Error!i64 {
return -@as(i64, @intCast(try decodePInt(iter, minor) + 1));
const n = try decodePInt(iter, minor);
if (n > maxInt(i64)) return error.IntegerTooSmall;
return -1 - @as(i64, @intCast(n));
}
pub fn decodeMapHeader(iter: *[]const u8) error{ TooShort, InvalidMapType, InvalidPIntType }!usize {