Skip to content

Commit 68194c6

Browse files
committed
Fix flush implementation on decompressobject
Correct implementation from zlibmodule.c. The do whiel blocks are now correctly translated
1 parent 582754c commit 68194c6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/isal/isal_zlib.pyx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,9 +671,9 @@ cdef class Decompress:
671671
cdef Py_ssize_t unused_bytes
672672

673673
try:
674-
while self.stream.block_state != ISAL_BLOCK_FINISH and ibuflen !=0:
674+
while True:
675675
arrange_input_buffer(&self.stream, &ibuflen)
676-
while (self.stream.block_state != ISAL_BLOCK_FINISH):
676+
while True:
677677
self.stream.next_out = obuf # Reset output buffer.
678678
self.stream.avail_out = obuflen
679679
err = isal_inflate(&self.stream)
@@ -685,9 +685,15 @@ cdef class Decompress:
685685
# Instead of output buffer resizing as the zlibmodule.c example
686686
# the data is appended to a list.
687687
# TODO: Improve this with the buffer protocol.
688+
if self.stream.avail_out == obuflen:
689+
break
688690
bytes_written = obuflen - self.stream.avail_out
689691
total_bytes += bytes_written
690692
out.append(obuf[:bytes_written])
693+
if self.stream.avail_out != 0:
694+
break
695+
if self.stream.block_state == ISAL_BLOCK_FINISH or ibuflen == 0:
696+
break
691697
self.save_unconsumed_input(buffer)
692698
return b"".join(out)
693699
finally:

0 commit comments

Comments
 (0)