Skip to content

Commit

Permalink
Fix gzip Decompression Support
Browse files Browse the repository at this point in the history
  • Loading branch information
BJap committed Aug 27, 2023
1 parent c395e1f commit e6f2d42
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions extmod/moduzlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,19 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
decomp->source_limit = (byte *)bufinfo.buf + bufinfo.len;

int st;
bool is_zlib = true;
mp_int_t wbits = 0;

if (n_args > 1 && MP_OBJ_SMALL_INT_VALUE(args[1]) < 0) {
is_zlib = false;
if (n_args > 1) {
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);
if (st < 0) {
goto error;
Expand Down

0 comments on commit e6f2d42

Please sign in to comment.