summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/vfprintf.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-10-16 12:09:43 +0000
committertjr <tjr@FreeBSD.org>2002-10-16 12:09:43 +0000
commit3a88c84c050889dfcdf58a721602c40f9ae03a96 (patch)
tree47fcbdba053baaebb80400ad1d663fa57af766bc /lib/libc/stdio/vfprintf.c
parentccd9275d4ea58567606a870a1c0faabbbabd889b (diff)
downloadFreeBSD-src-3a88c84c050889dfcdf58a721602c40f9ae03a96.zip
FreeBSD-src-3a88c84c050889dfcdf58a721602c40f9ae03a96.tar.gz
Set the error bit on the stream if an encoding error occurs. Improve
handling of multibyte sequences representing null wide characters.
Diffstat (limited to 'lib/libc/stdio/vfprintf.c')
-rw-r--r--lib/libc/stdio/vfprintf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index c1b4e0b..b0084c8 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -759,8 +759,10 @@ reswitch: switch (ch) {
memset(&mbs, 0, sizeof(mbs));
mbseqlen = wcrtomb(cp = buf,
(wchar_t)GETARG(wint_t), &mbs);
- if (mbseqlen == (size_t)-1)
+ if (mbseqlen == (size_t)-1) {
+ fp->_flags |= __SERR;
goto error;
+ }
size = (int)mbseqlen;
} else {
*(cp = buf) = GETARG(int);
@@ -934,8 +936,10 @@ fp_begin: if (prec == -1)
cp = "(null)";
else {
convbuf = __wcsconv(wcp, prec);
- if (convbuf == NULL)
+ if (convbuf == NULL) {
+ fp->_flags |= __SERR;
goto error;
+ }
cp = convbuf;
}
} else if ((cp = GETARG(char *)) == NULL)
OpenPOWER on IntegriCloud