Date: Sun, 4 Sep 2016 00:34:15 +0000 (UTC) From: "Andrey A. Chernov" <ache@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r305369 - stable/10/lib/libc/stdio Message-ID: <201609040034.u840YFOu023110@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ache Date: Sun Sep 4 00:34:15 2016 New Revision: 305369 URL: https://svnweb.freebsd.org/changeset/base/305369 Log: MFC r305219 If error happens, don't overwrite original errno comes from __mbrtowc() and __srefill(). Modified: stable/10/lib/libc/stdio/fgetwc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/stdio/fgetwc.c ============================================================================== --- stable/10/lib/libc/stdio/fgetwc.c Sun Sep 4 00:29:48 2016 (r305368) +++ stable/10/lib/libc/stdio/fgetwc.c Sun Sep 4 00:34:15 2016 (r305369) @@ -84,9 +84,10 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, i return (WEOF); do { nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs); - if (nconv == (size_t)-1) - break; - else if (nconv == (size_t)-2) + if (nconv == (size_t)-1) { + fp->_flags |= __SERR; + return (WEOF); + } else if (nconv == (size_t)-2) continue; else if (nconv == 0) { fp->_p++; @@ -100,7 +101,9 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, i return (wc); } } while (__srefill(fp) == 0); - fp->_flags |= __SERR; - errno = EILSEQ; + if (__sfeof(fp)) { + fp->_flags |= __SERR; + errno = EILSEQ; + } return (WEOF); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609040034.u840YFOu023110>