summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-03-30 06:13:58 +0000
committerpfg <pfg@FreeBSD.org>2016-03-30 06:13:58 +0000
commit3b7dd3908649871ac4cbd66a47ff4c055b7c82a8 (patch)
tree04fd078a7c64dacafd9c18520f4837a749a87659 /lib
parentdd505c7bdadb032f6e8d5b063b17b0044d3c1983 (diff)
downloadFreeBSD-src-3b7dd3908649871ac4cbd66a47ff4c055b7c82a8.zip
FreeBSD-src-3b7dd3908649871ac4cbd66a47ff4c055b7c82a8.tar.gz
freopen(3): prevent uninitialized errno.
Revert r297407 and redo it cleanly. Pointed out by: Jukka A. Ukkonen CID: 1018720 MFC after: 1 week
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdio/freopen.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/stdio/freopen.c b/lib/libc/stdio/freopen.c
index 13c19a7..8138a6b 100644
--- a/lib/libc/stdio/freopen.c
+++ b/lib/libc/stdio/freopen.c
@@ -66,8 +66,7 @@ freopen(const char * __restrict file, const char * __restrict mode,
(void) fclose(fp);
errno = sverrno;
return (NULL);
- } else
- sverrno = 0;
+ }
FLOCKFILE(fp);
@@ -79,6 +78,7 @@ freopen(const char * __restrict file, const char * __restrict mode,
* re-open the same file with a different mode. We allow this only
* if the modes are compatible.
*/
+ sverrno = 0;
if (file == NULL) {
/* See comment below regarding freopen() of closed files. */
if (fp->_flags == 0) {
OpenPOWER on IntegriCloud