@@ -556,18 +556,23 @@ cdef class Decompress:
556
556
cdef save_unconsumed_input(self , Py_buffer * data):
557
557
cdef Py_ssize_t old_size, new_size, left_size
558
558
cdef bytes new_data
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" "
564
559
if self .stream.block_state == ISAL_BLOCK_FINISH:
565
560
self .eof = 1
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
- else :
561
+ if self .stream.avail_in > 0 :
562
+ left_size = < unsigned char * > data.buf + data.len - self .stream.next_in
563
+ new_data = PyBytes_FromStringAndSize(< char * > self .stream.next_in, left_size)
564
+ else :
565
+ new_data = b" "
566
+ if not self .unused_data:
567
+ # The block is finished and this decompressobject can not be
568
+ # used anymore. Some unused data is in the bitbuffer and has to
569
+ # be recovered. Only when self.unused_data is empty. Otherwise
570
+ # we assume the bitbuffer data is already added.
571
+ self .unused_data = self ._view_bitbuffer()
572
+ self .unused_data += new_data
573
+ elif self .stream.avail_in > 0 or self .unconsumed_tail:
574
+ left_size = < unsigned char * > data.buf + data.len - self .stream.next_in
575
+ new_data = PyBytes_FromStringAndSize(< char * > self .stream.next_in, left_size)
571
576
self .unconsumed_tail = new_data
572
577
573
578
def decompress (self , data , Py_ssize_t max_length = 0 ):
0 commit comments