fix reading input stream during decompression

By using read instead of readAll decompression reader could get bytes
then available in the stream and then later wrongly failed with end of
stream.
This commit is contained in:
Igor Anić 2024-02-14 13:32:19 +01:00
parent cb3fe277bb
commit f81b3a2095

View File

@ -55,7 +55,7 @@ pub fn BitReader(comptime ReaderType: type) type {
(self.nbits >> 3); // 0 for 0-7, 1 for 8-16, ... same as / 8
var buf: [8]u8 = [_]u8{0} ** 8;
const bytes_read = self.forward_reader.read(buf[0..empty_bytes]) catch 0;
const bytes_read = self.forward_reader.readAll(buf[0..empty_bytes]) catch 0;
if (bytes_read > 0) {
const u: u64 = std.mem.readInt(u64, buf[0..8], .little);
self.bits |= u << @as(u6, @intCast(self.nbits));