svn commit: r298312 - head/lib/libc/tests/stdio
Garrett Cooper
ngie at FreeBSD.org
Wed Apr 20 00:19:06 UTC 2016
Author: ngie
Date: Wed Apr 20 00:19:04 2016
New Revision: 298312
URL: https://svnweb.freebsd.org/changeset/base/298312
Log:
Fix double fclose of `fp1` when freopen fails
freopen handles closing file descriptors on error, with the exception of
fdopen'ed descriptors, so closing an already fclose'd file descriptor is
incorrect
CID: 1338525
Differential Revision: https://reviews.freebsd.org/D6013
MFC after: 2 weeks
Reported by: Coverity
Sponsored by: EMC / Isilon Storage Division
Modified:
head/lib/libc/tests/stdio/freopen_test.c
Modified: head/lib/libc/tests/stdio/freopen_test.c
==============================================================================
--- head/lib/libc/tests/stdio/freopen_test.c Tue Apr 19 23:59:10 2016 (r298311)
+++ head/lib/libc/tests/stdio/freopen_test.c Wed Apr 20 00:19:04 2016 (r298312)
@@ -48,7 +48,6 @@ runtest(const char *fname1, const char *
"fopen(\"%s\", \"%s\") failed; errno=%d", fname1, mode1, errno);
fp2 = freopen(fname2, mode2, fp1);
if (fp2 == NULL) {
- fclose(fp1);
ATF_REQUIRE_MSG(success == false,
"freopen(\"%s\", \"%s\", fopen(\"%s\", \"%s\")) succeeded "
"unexpectedly", fname2_print, mode2, fname1, mode1);
More information about the svn-src-head
mailing list