From 18c8b420e248b0c0dad6cb8acfca099488d03300 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sat, 17 Aug 2024 05:31:05 +0300 Subject: [PATCH] printf: fixed handling of 0 values in conversions --- kern/src/libc/stdio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kern/src/libc/stdio.c b/kern/src/libc/stdio.c index f2a9619..f34c1f7 100644 --- a/kern/src/libc/stdio.c +++ b/kern/src/libc/stdio.c @@ -165,7 +165,7 @@ static int wrint(struct outbuf *outbuf, struct format *fmt, long val) } if(val == 0) { - *ptr++ = '0'; + *--ptr = '0'; } switch(fmt->base) { @@ -208,7 +208,7 @@ static int wruint(struct outbuf *outbuf, struct format *fmt, unsigned long val) buf[15] = 0; if(val == 0) { - *ptr++ = '0'; + *--ptr = '0'; } switch(fmt->base) { -- 1.7.10.4