mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.mem.readVarInt: assert ReturnType is large enough (#20946)
Fixes #20521
This commit is contained in:
parent
13fb68c064
commit
0367f18cb9
1 changed files with 1 additions and 0 deletions
|
|
@ -1602,6 +1602,7 @@ test containsAtLeast {
|
|||
/// T specifies the return type, which must be large enough to store
|
||||
/// the result.
|
||||
pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian) ReturnType {
|
||||
assert(@typeInfo(ReturnType).int.bits >= bytes.len * 8);
|
||||
const bits = @typeInfo(ReturnType).int.bits;
|
||||
const signedness = @typeInfo(ReturnType).int.signedness;
|
||||
const WorkType = std.meta.Int(signedness, @max(16, bits));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue