From owner-svn-src-stable-10@freebsd.org Sun Sep 4 00:34:17 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 02927A9435F; Sun, 4 Sep 2016 00:34:17 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C42A1132; Sun, 4 Sep 2016 00:34:16 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u840YF3j023111; Sun, 4 Sep 2016 00:34:15 GMT (envelope-from ache@FreeBSD.org) Received: (from ache@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u840YFOu023110; Sun, 4 Sep 2016 00:34:15 GMT (envelope-from ache@FreeBSD.org) Message-Id: <201609040034.u840YFOu023110@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ache set sender to ache@FreeBSD.org using -f From: "Andrey A. Chernov" Date: Sun, 4 Sep 2016 00:34:15 +0000 (UTC) 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 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Sep 2016 00:34:17 -0000 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); }