summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/vfprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'userland/libc/stdio/vfprintf.c')
-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] = '-';