summaryrefslogtreecommitdiff
path: root/libc/stdio
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdio')
-rw-r--r--libc/stdio/_vfprintf.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libc/stdio/_vfprintf.c b/libc/stdio/_vfprintf.c
index 3b007084d..fa5dc44fc 100644
--- a/libc/stdio/_vfprintf.c
+++ b/libc/stdio/_vfprintf.c
@@ -1670,6 +1670,9 @@ static int _do_one_spec(FILE * __restrict stream,
#endif
s = "(null)";
slen = 6;
+ /* Use an empty string rather than truncation if precision is too small. */
+ if (ppfs->info.prec >= 0 && ppfs->info.prec < slen)
+ slen = 0;
}
} else { /* char */
s = buf;
@@ -1726,6 +1729,9 @@ static int _do_one_spec(FILE * __restrict stream,
NULL_STRING:
s = "(null)";
SLEN = slen = 6;
+ /* Use an empty string rather than truncation if precision is too small. */
+ if (ppfs->info.prec >= 0 && ppfs->info.prec < slen)
+ SLEN = slen = 0;
}
} else { /* char */
*wbuf = btowc( (unsigned char)(*((const int *) *argptr)) );