Skip to content

Commit 36c0d81

Browse files
committed
Fix gzip Decompression Support
1 parent c395e1f commit 36c0d81

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

extmod/moduzlib.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,18 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
175175
decomp->source_limit = (byte *)bufinfo.buf + bufinfo.len;
176176

177177
int st;
178-
bool is_zlib = true;
178+
mp_int_t wbits = 0;
179179

180-
if (n_args > 1 && MP_OBJ_SMALL_INT_VALUE(args[1]) < 0) {
181-
is_zlib = false;
180+
if (n_args > 1) {
181+
wbits = MP_OBJ_SMALL_INT_VALUE(args[1]);
182182
}
183183

184-
if (is_zlib) {
184+
if (wbits >= 16) {
185+
st = uzlib_gzip_parse_header(decomp);
186+
if (st < 0) {
187+
goto error;
188+
}
189+
} else if (wbits >= 0) {
185190
st = uzlib_zlib_parse_header(decomp);
186191
if (st < 0) {
187192
goto error;

0 commit comments

Comments
 (0)