Skip to content

Commit 8f739ef

Browse files
committed
Correct bitbuffer view
1 parent 5f220c1 commit 8f739ef

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/isal/isal_zlib.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,14 +544,16 @@ cdef class Decompress:
544544
"""Shows the 64-bitbuffer of the internal inflate_state. It contains
545545
a maximum of 8 bytes. This data is already read-in so is not part
546546
of the unconsumed tail."""
547-
read_in_length = self.stream.read_in_length // 8
547+
bits_in_buffer = self.stream.read_in_length
548+
read_in_length = bits_in_buffer // 8
548549
if read_in_length == 0:
549550
return b""
551+
remainder = bits_in_buffer % 8
550552
read_in = self.stream.read_in
551553
# The bytes are added by bitshifting, so in reverse order. Reading the
552554
# 64-bit integer into 8 bytes little-endian provides the characters in
553555
# the correct order.
554-
return read_in.to_bytes(8, "little")[:read_in_length]
556+
return (read_in >> remainder).to_bytes(8, "little")[:read_in_length]
555557

556558
cdef save_unconsumed_input(self, Py_buffer *data):
557559
cdef Py_ssize_t old_size, new_size, left_size

0 commit comments

Comments
 (0)