Skip to content

Commit 04e9274

Browse files
committed
Fix bug where dictionaries could not be used with decompressobj
1 parent 8224b81 commit 04e9274

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/isal/isal_zlibmodule.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,14 +724,27 @@ isal_zlib_Decompress_decompress_impl(decompobject *self, Py_buffer *data,
724724
Py_BEGIN_ALLOW_THREADS
725725
err = isal_inflate(&self->zst);
726726
Py_END_ALLOW_THREADS
727-
728-
if (err != ISAL_DECOMP_OK){
729-
isal_inflate_error(err);
730-
goto abort;
727+
switch(err) {
728+
case ISAL_DECOMP_OK:
729+
break;
730+
case ISAL_NEED_DICT:
731+
if (self->zdict != NULL) {
732+
if (set_inflate_zdict(self) < 0) {
733+
goto abort;
734+
}
735+
else
736+
break;
737+
}
738+
else {
739+
isal_inflate_error(err);
740+
goto abort;
741+
}
742+
default:
743+
isal_inflate_error(err);
744+
goto abort;
731745
}
732746

733-
} while (self->zst.avail_out == 0 &&
734-
self->zst.block_state != ISAL_BLOCK_FINISH);
747+
} while (self->zst.avail_out == 0 || err == ISAL_NEED_DICT);
735748

736749
} while (self->zst.block_state != ISAL_BLOCK_FINISH && ibuflen != 0);
737750

0 commit comments

Comments
 (0)