Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Mar 2016 06:13:58 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r297408 - head/lib/libc/stdio
Message-ID:  <201603300613.u2U6DwGv026746@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Wed Mar 30 06:13:58 2016
New Revision: 297408
URL: https://svnweb.freebsd.org/changeset/base/297408

Log:
  freopen(3): prevent uninitialized errno.
  
  Revert r297407 and redo it cleanly.
  
  Pointed out by:	Jukka A. Ukkonen
  CID:		1018720
  MFC after:	1 week

Modified:
  head/lib/libc/stdio/freopen.c

Modified: head/lib/libc/stdio/freopen.c
==============================================================================
--- head/lib/libc/stdio/freopen.c	Wed Mar 30 01:32:08 2016	(r297407)
+++ head/lib/libc/stdio/freopen.c	Wed Mar 30 06:13:58 2016	(r297408)
@@ -66,8 +66,7 @@ freopen(const char * __restrict file, co
 		(void) fclose(fp);
 		errno = sverrno;
 		return (NULL);
-	} else
-		sverrno = 0;
+	}
 
 	FLOCKFILE(fp);
 
@@ -79,6 +78,7 @@ freopen(const char * __restrict file, co
 	 * 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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201603300613.u2U6DwGv026746>