aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2018-05-02 23:16:22 +1000
committerDamien George2018-05-02 23:16:22 +1000
commit59361681501cda2aa998fda649929591308aaebb (patch)
treedaf6024269fc6cc7ee44346a64121e0d98a0a216
parent4fa7d36cee5dcda836409999612a5022f2d59952 (diff)
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 #3690.
-rw-r--r--extmod/uzlib/tinflate.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/extmod/uzlib/tinflate.c b/extmod/uzlib/tinflate.c
index 58850eb4a..21558af5b 100644
--- a/extmod/uzlib/tinflate.c
+++ b/extmod/uzlib/tinflate.c
@@ -394,9 +394,11 @@ static int tinf_inflate_uncompressed_block(TINF_DATA *d)
unsigned int length, invlength;
/* get length */
- length = uzlib_get_byte(d) + 256 * uzlib_get_byte(d);
+ length = uzlib_get_byte(d);
+ length += 256 * uzlib_get_byte(d);
/* get one's complement of length */
- invlength = uzlib_get_byte(d) + 256 * uzlib_get_byte(d);
+ invlength = uzlib_get_byte(d);
+ invlength += 256 * uzlib_get_byte(d);
/* check length */
if (length != (~invlength & 0x0000ffff)) return TINF_DATA_ERROR;