flate zlib fix end of block reading

`n` is wanted number of bits to toss
`buffered_n` is actual number of bytes in `next_int`
This commit is contained in:
Igor Anić 2025-08-05 18:47:22 +02:00 committed by Andrew Kelley
parent d8cecffe31
commit d2149106a6

View file

@ -603,7 +603,7 @@ fn tossBitsEnding(d: *Decompress, n: u4) !void {
error.EndOfStream => unreachable, error.EndOfStream => unreachable,
}; };
d.next_bits = next_int >> needed_bits; d.next_bits = next_int >> needed_bits;
d.remaining_bits = @intCast(@as(usize, n) * 8 -| @as(usize, needed_bits)); d.remaining_bits = @intCast(@as(usize, buffered_n) * 8 -| @as(usize, needed_bits));
} }
fn takeBitsRuntime(d: *Decompress, n: u4) !u16 { fn takeBitsRuntime(d: *Decompress, n: u4) !u16 {