From 747b8d8f71ed5b557234feffa44ff1ed98bed39b Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Thu, 27 Jul 2017 23:51:36 -0500 Subject: [PATCH] stb_sprintf.h: Don't compare uninitialized value when using zero. This prevents a "Conditional jump or move depends on uninitialised value(s)" error from valgrind when using zero as an argument in line 1045. --- stb_sprintf.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stb_sprintf.h b/stb_sprintf.h index 3828445..abf4371 100644 --- a/stb_sprintf.h +++ b/stb_sprintf.h @@ -12,6 +12,7 @@ // github:d26435 // github:trex78 // Jari Komppa (SI suffixes) +// Rohit Nirmal // // LICENSE: // @@ -1025,11 +1026,11 @@ STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(vsprintfcb)(STBSP_SPRINTFCB *callback, n64 = 0; } if ((fl & STBSP__TRIPLET_COMMA) == 0) { - while (n) { + do { s -= 2; *(stbsp__uint16 *)s = *(stbsp__uint16 *)&stbsp__digitpair[(n % 100) * 2]; n /= 100; - } + } while (n); } while (n) { if ((fl & STBSP__TRIPLET_COMMA) && (l++ == 3)) {