Fix gzip Decompression Support

This commit is contained in:
Bobby Jap 2023-08-26 18:50:35 -07:00
parent c395e1f9f7
commit 36c0d81af8
1 changed files with 9 additions and 4 deletions

View File

@ -175,13 +175,18 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
decomp->source_limit = (byte *)bufinfo.buf + bufinfo.len; decomp->source_limit = (byte *)bufinfo.buf + bufinfo.len;
int st; int st;
bool is_zlib = true; mp_int_t wbits = 0;
if (n_args > 1 && MP_OBJ_SMALL_INT_VALUE(args[1]) < 0) { if (n_args > 1) {
is_zlib = false; wbits = MP_OBJ_SMALL_INT_VALUE(args[1]);
} }
if (is_zlib) { if (wbits >= 16) {
st = uzlib_gzip_parse_header(decomp);
if (st < 0) {
goto error;
}
} else if (wbits >= 0) {
st = uzlib_zlib_parse_header(decomp); st = uzlib_zlib_parse_header(decomp);
if (st < 0) { if (st < 0) {
goto error; goto error;