printf: fixed handling of 0 values in conversions
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 17 Aug 2024 02:31:05 +0000 (05:31 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 17 Aug 2024 02:31:05 +0000 (05:31 +0300)
kern/src/libc/stdio.c

index f2a9619..f34c1f7 100644 (file)
@@ -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) {