authorgravatar for srazin123@gmail.compoypoyan <srazin123@gmail.com> 2024-10-12 03:32:10+08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-10-11 19:32:10+00:00
log0367f18cb9dc61090c27e29572a50810b9809822
treec6e6a9508c3051c251452a3f2ad45e859fd798ff
parent13fb68c064900cee67583e603d8c2acf41770663
signaturebadge-check Signed by PGP key B5690EEEBB952194

std.mem.readVarInt: assert ReturnType is large enough (#20946)

Fixes #20521

1 files changed, 1 insertions(+), 0 deletions(-)

lib/std/mem.zig+1
...@@ -1602,6 +1602,7 @@ test containsAtLeast {...@@ -1602,6 +1602,7 @@ test containsAtLeast {
1602/// T specifies the return type, which must be large enough to store1602/// T specifies the return type, which must be large enough to store
1603/// the result.1603/// the result.
1604pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian) ReturnType {1604pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian) ReturnType {
1605 assert(@typeInfo(ReturnType).int.bits >= bytes.len * 8);
1605 const bits = @typeInfo(ReturnType).int.bits;1606 const bits = @typeInfo(ReturnType).int.bits;
1606 const signedness = @typeInfo(ReturnType).int.signedness;1607 const signedness = @typeInfo(ReturnType).int.signedness;
1607 const WorkType = std.meta.Int(signedness, @max(16, bits));1608 const WorkType = std.meta.Int(signedness, @max(16, bits));