diff options
Diffstat (limited to 'stdio/vfprintf.c')
-rw-r--r-- | stdio/vfprintf.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/stdio/vfprintf.c b/stdio/vfprintf.c index 1246229a63..06aa0a0e7d 100644 --- a/stdio/vfprintf.c +++ b/stdio/vfprintf.c @@ -533,21 +533,16 @@ vfprintf (s, format, ap) } else if (specs[cnt].info.prec != -1) { + /* Search for the end of the string, but don't search + past the length specified by the precision. */ const char *end = memchr (str, '\0', specs[cnt].info.prec); if (end) len = end - str; else - len = strlen (str); - } - else - { - len = strlen (str); - - if (specs[cnt].info.prec != -1 - && (size_t) specs[cnt].info.prec < len) - /* Limit the length to the precision. */ len = specs[cnt].info.prec; } + else + len = strlen (str); specs[cnt].info.width -= len; |