Skip to content

Commit 7aede1b

Browse files
authored
Merge pull request #2245 from zhaojuntao/fix-sprintf
[src][kservice.c] 修复 snprintf 中 `print_number` 函数错误解析 `%.0d` format 的问题
2 parents 71da339 + 5c76d3d commit 7aede1b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/kservice.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ static char *print_number(char *buf,
601601
#else
602602
char tmp[16];
603603
#endif
604+
int precision_bak = precision;
604605
const char *digits;
605606
static const char small_digits[] = "0123456789abcdef";
606607
static const char large_digits[] = "0123456789ABCDEF";
@@ -724,7 +725,7 @@ static char *print_number(char *buf,
724725
#endif
725726

726727
/* put number in the temporary buffer */
727-
while (i-- > 0)
728+
while (i-- > 0 && (precision_bak != 0))
728729
{
729730
if (buf <= end)
730731
*buf = tmp[i];

0 commit comments

Comments
 (0)