Skip to content

Commit 22d09aa

Browse files
committed
Fix one bug in unused_data
1 parent 8f884bf commit 22d09aa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/isal/isal_zlib.pyx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,14 @@ cdef class Decompress:
540540
if self.obuf is not NULL:
541541
PyMem_Free(self.obuf)
542542

543+
cdef bytes consume_read_in(self):
544+
read_in_length = self.stream.read_in_length // 8
545+
if read_in_length == 0:
546+
return b""
547+
read_in = self.stream.read_in
548+
result = read_in.to_bytes(8, "little")[:read_in_length]
549+
return read_in.to_bytes(8, "little")[:read_in_length]
550+
543551
cdef save_unconsumed_input(self, Py_buffer *data):
544552
cdef Py_ssize_t old_size, new_size, left_size
545553
cdef bytes new_data
@@ -551,7 +559,7 @@ cdef class Decompress:
551559
if left_size > (PY_SSIZE_T_MAX - old_size):
552560
raise MemoryError()
553561
new_data = PyBytes_FromStringAndSize(<char *>self.stream.next_in, left_size)
554-
self.unused_data += new_data
562+
self.unused_data = self.consume_read_in() + new_data
555563
if self.stream.avail_in > 0 or self.unconsumed_tail:
556564
left_size = <unsigned char*>data.buf + data.len - self.stream.next_in
557565
new_data = PyBytes_FromStringAndSize(<char *>self.stream.next_in, left_size)

0 commit comments

Comments
 (0)