summaryrefslogtreecommitdiff
path: root/userland/libc
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-06-26 21:47:15 +0200
committerAnton Kling <anton@kling.gg>2024-06-26 21:47:15 +0200
commitfddda835a28bbc52a8d8450395a3e57e181782a8 (patch)
treef515f65858621e6979bb847848929c9102e8f2d8 /userland/libc
parente15065fe45f8004adcc8b69bbbe680ced0d530a1 (diff)
LibC: Fix regression in printf
printf did not write out anything for %d when the value was zero.
Diffstat (limited to 'userland/libc')
-rw-r--r--userland/libc/stdio/vfprintf.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/userland/libc/stdio/vfprintf.c b/userland/libc/stdio/vfprintf.c
index 2ba3e2c..d384c1d 100644
--- a/userland/libc/stdio/vfprintf.c
+++ b/userland/libc/stdio/vfprintf.c
@@ -28,8 +28,13 @@ int fprint_num(FILE *f, long long n, int base, char *char_set, int prefix,
n *= -1;
}
- for (; n != 0 && i < 32; i++, n /= base)
- str[i] = char_set[(n % base)];
+ if (0 == n) {
+ str[i] = char_set[0];
+ i++;
+ } else {
+ for (; n != 0 && i < 32; i++, n /= base)
+ str[i] = char_set[(n % base)];
+ }
if (is_signed) {
str[i] = '-';