Merge pull request #2245 from zhaojuntao/fix-sprintf

[src][kservice.c] 修复 snprintf 中 `print_number` 函数错误解析 `%.0d` format 的问题
This commit is contained in:
Bernard Xiong 2019-01-25 10:29:24 +08:00 committed by GitHub
commit 7aede1befb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -601,6 +601,7 @@ static char *print_number(char *buf,
#else #else
char tmp[16]; char tmp[16];
#endif #endif
int precision_bak = precision;
const char *digits; const char *digits;
static const char small_digits[] = "0123456789abcdef"; static const char small_digits[] = "0123456789abcdef";
static const char large_digits[] = "0123456789ABCDEF"; static const char large_digits[] = "0123456789ABCDEF";
@ -724,7 +725,7 @@ static char *print_number(char *buf,
#endif #endif
/* put number in the temporary buffer */ /* put number in the temporary buffer */
while (i-- > 0) while (i-- > 0 && (precision_bak != 0))
{ {
if (buf <= end) if (buf <= end)
*buf = tmp[i]; *buf = tmp[i];