summaryrefslogtreecommitdiff
path: root/stdio-common/vfprintf.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 15:21:13 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 15:21:13 +0000
commit05b4aead80b82c3bd95110e57e3eee2bf977284f (patch)
tree11e054dbcf3a96d9e66d11bf26921b0d6693e407 /stdio-common/vfprintf.c
parent0f2401c5eaf467c499f3b7ed58773b6ca5316acc (diff)
downloadglibc-05b4aead80b82c3bd95110e57e3eee2bf977284f.tar
glibc-05b4aead80b82c3bd95110e57e3eee2bf977284f.tar.gz
glibc-05b4aead80b82c3bd95110e57e3eee2bf977284f.tar.bz2
glibc-05b4aead80b82c3bd95110e57e3eee2bf977284f.zip
2007-05-06 Ulrich Drepper <drepper@redhat.com>
* stdio-common/vfprintf.c (process_string_arg): Optimize ridiculous precision in wide char code printing multi-byte string. Reported by Jim Meyering <jim@meyering.net>.
Diffstat (limited to 'stdio-common/vfprintf.c')
-rw-r--r--stdio-common/vfprintf.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index b92d1c4b64..1377e3c17e 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -1025,10 +1025,11 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
const char *mbs = (const char *) string; \
mbstate_t mbstate; \
\
- len = prec != -1 ? (size_t) prec : strlen (mbs); \
+ len = prec != -1 ? __strnlen (mbs, (size_t) prec) : strlen (mbs); \
\
/* Allocate dynamically an array which definitely is long \
- enough for the wide character version. */ \
+ enough for the wide character version. Each byte in the \
+ multi-byte string can produce at most one wide character. */ \
if (__libc_use_alloca (len * sizeof (wchar_t))) \
string = (CHAR_T *) alloca (len * sizeof (wchar_t)); \
else if ((string = (CHAR_T *) malloc (len * sizeof (wchar_t))) \