Skip to content

Commit 9f70900

Browse files
committed
Always update unconsumed tail
1 parent ebfd459 commit 9f70900

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/isal/isal_zlib.pyx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -556,17 +556,18 @@ cdef class Decompress:
556556
cdef save_unconsumed_input(self, Py_buffer *data):
557557
cdef Py_ssize_t old_size, new_size, left_size
558558
cdef bytes new_data
559-
left_size = <unsigned char*>data.buf + data.len - self.stream.next_in
560-
new_data = PyBytes_FromStringAndSize(<char *>self.stream.next_in, left_size)
559+
if self.stream.avail_in > 0:
560+
left_size = <unsigned char*>data.buf + data.len - self.stream.next_in
561+
new_data = PyBytes_FromStringAndSize(<char *>self.stream.next_in, left_size)
562+
else:
563+
new_data = b""
561564
if self.stream.block_state == ISAL_BLOCK_FINISH:
562565
self.eof = 1
563-
if self.stream.avail_in > 0 or self._view_bitbuffer():
564-
# The block is finished and this decompressobject can not be
565-
# used anymore. Some unused data is in the bitbuffer and has to
566-
# be recovered.
567-
self.unused_data = self._view_bitbuffer() + new_data
568-
if self.stream.avail_in > 0:
569-
self.unconsumed_tail = new_data
566+
# The block is finished and this decompressobject can not be
567+
# used anymore. Some unused data is in the bitbuffer and has to
568+
# be recovered.
569+
self.unused_data = self._view_bitbuffer() + new_data
570+
self.unconsumed_tail = new_data
570571

571572
def decompress(self, data, Py_ssize_t max_length = 0):
572573
"""

0 commit comments

Comments
 (0)