Skip to content

Commit 5c76d3d

Browse files
committed
[src][kservice.c] 修复 snprintf 中 print_number 函数错误解析 .0 format 的问题
Signed-off-by: MurphyZhao <[email protected]>
1 parent 929e9c8 commit 5c76d3d

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)