summary refs log tree commit diff
path: root/stdio-common
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-05-07 03:44:48 +0000
committerUlrich Drepper <drepper@redhat.com>2007-05-07 03:44:48 +0000
commit49a8eb75ebdecc5bdf15c9f5efa0b78ef2f150d2 (patch)
tree689b70e039401782d72d0725ef1b25acac5059f8 /stdio-common
parentffecd39b9ce741b74c53b7d5e7e9571e2f25f795 (diff)
downloadglibc-49a8eb75ebdecc5bdf15c9f5efa0b78ef2f150d2.tar.gz
glibc-49a8eb75ebdecc5bdf15c9f5efa0b78ef2f150d2.tar.xz
glibc-49a8eb75ebdecc5bdf15c9f5efa0b78ef2f150d2.zip
* 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')
-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 4f0d971c55..20638ad1fd 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -1026,10 +1026,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)))    \