summaryrefslogtreecommitdiff
path: root/stdio-common/vfprintf.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-05-04 10:05:57 +0000
committerJakub Jelinek <jakub@redhat.com>2007-05-04 10:05:57 +0000
commit2a0a747e57ec96bab9d4a6b7c0b32df82a41316e (patch)
tree002d92f89d7109abc1c2ebe7f113f8dee0dc3034 /stdio-common/vfprintf.c
parentaf5726aed8a0c87d7f29570641cf0acb6a92f918 (diff)
Updated to fedora-glibc-20070504T0917cvs/fedora-glibc-2_5_90-22
Diffstat (limited to 'stdio-common/vfprintf.c')
-rw-r--r--stdio-common/vfprintf.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 946551f2d6..4f0d971c55 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -1160,19 +1160,26 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
else \
{ \
/* In case we have a multibyte character set the \
- situation is more compilcated. We must not copy \
+ situation is more complicated. We must not copy \
bytes at the end which form an incomplete character. */\
- wchar_t ignore[prec]; \
+ size_t ignore_size = (unsigned) prec > 1024 ? 1024 : prec;\
+ wchar_t ignore[ignore_size]; \
const char *str2 = string; \
- mbstate_t ps; \
+ const char *strend = string + prec; \
+ if (strend < string) \
+ strend = (const char *) UINTPTR_MAX; \
\
+ mbstate_t ps; \
memset (&ps, '\0', sizeof (ps)); \
- if (__mbsnrtowcs (ignore, &str2, prec, prec, &ps) \
- == (size_t) -1) \
- { \
- done = -1; \
- goto all_done; \
- } \
+ \
+ while (str2 != NULL && str2 < strend) \
+ if (__mbsnrtowcs (ignore, &str2, strend - str2, \
+ ignore_size, &ps) == (size_t) -1) \
+ { \
+ done = -1; \
+ goto all_done; \
+ } \
+ \
if (str2 == NULL) \
len = strlen (string); \
else \