From ed2be79b4930f620083256fcb5b4faf9091c9ffc Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 22 Dec 2019 22:16:32 +1100 Subject: [PATCH] extmod/uzlib: Explicitly cast ptr-diff-expr to unsigned. The struct member "dest" should never be less than "destStart", so their difference is never negative. Cast as such to make the comparison explicitly unsigned, ensuring the compiler produces the correct comparison instruction, and avoiding any compiler warnings. --- extmod/uzlib/tinflate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extmod/uzlib/tinflate.c b/extmod/uzlib/tinflate.c index b93bc1fa36..045952c755 100644 --- a/extmod/uzlib/tinflate.c +++ b/extmod/uzlib/tinflate.c @@ -464,7 +464,7 @@ static int tinf_inflate_block_data(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt) } } else { /* catch trying to point before the start of dest buffer */ - if (offs > d->dest - d->destStart) { + if (offs > (unsigned int)(d->dest - d->destStart)) { return TINF_DATA_ERROR; } d->lzOff = -offs;