]> granicus.if.org Git - curl/commitdiff
mprintf: avoid unsigned integer overflow warning
authorTim Rühsen <tim.ruehsen@gmx.de>
Sun, 28 Oct 2018 10:33:27 +0000 (11:33 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 2 Nov 2018 10:07:04 +0000 (11:07 +0100)
The overflow has no real world impact.
Just avoid it for "best practice".

Code change suggested by "The Infinnovation Team" and Daniel Stenberg.
Closes #3184

lib/mprintf.c

index d2d91d7438783905bc83c2757b828cb6ce00734e..e1909367824d3cc0471219d2f2eefac5fb513d33 100644 (file)
@@ -835,7 +835,7 @@ static int dprintf_formatf(
           while(width-- > 0)
             OUTCHAR(' ');
 
-        while((len-- > 0) && *str)
+        for(; len && *str; len--)
           OUTCHAR(*str++);
         if(p->flags&FLAGS_LEFT)
           while(width-- > 0)