Skip to content

Commit 5936168

Browse files
committed
extmod/uzlib: Fix C-language sequencing error with uzlib_get_byte calls.
The order of function calls in an arithmetic expression is undefined and so they must be written out as sequential statements. Thanks to @dv-extrarius for reporting this issue, see issue adafruit#3690.
1 parent 4fa7d36 commit 5936168

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

extmod/uzlib/tinflate.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,11 @@ static int tinf_inflate_uncompressed_block(TINF_DATA *d)
394394
unsigned int length, invlength;
395395

396396
/* get length */
397-
length = uzlib_get_byte(d) + 256 * uzlib_get_byte(d);
397+
length = uzlib_get_byte(d);
398+
length += 256 * uzlib_get_byte(d);
398399
/* get one's complement of length */
399-
invlength = uzlib_get_byte(d) + 256 * uzlib_get_byte(d);
400+
invlength = uzlib_get_byte(d);
401+
invlength += 256 * uzlib_get_byte(d);
400402
/* check length */
401403
if (length != (~invlength & 0x0000ffff)) return TINF_DATA_ERROR;
402404

0 commit comments

Comments
 (0)