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
This commit is contained in:
ngie 2016-04-20 00:19:04 +00:00
parent ef837f8229
commit c812be1395

View File

@ -48,7 +48,6 @@ runtest(const char *fname1, const char *mode1, const char *fname2,
"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);