From: Lasse Collin Date: Sat, 28 May 2011 13:43:26 +0000 (+0300) Subject: Don't call close(-1) in tuklib_open_stdxxx() on error. X-Git-Tag: v5.1.2alpha~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc4d4436969bd4d71b704d400a165875e596034a;p=thirdparty%2Fxz.git Don't call close(-1) in tuklib_open_stdxxx() on error. Thanks to Jim Meyering. --- diff --git a/src/common/tuklib_open_stdxxx.c b/src/common/tuklib_open_stdxxx.c index 08bc60d8..26702a6a 100644 --- a/src/common/tuklib_open_stdxxx.c +++ b/src/common/tuklib_open_stdxxx.c @@ -39,12 +39,14 @@ tuklib_open_stdxxx(int err_status) | (i == 0 ? O_WRONLY : O_RDONLY)); if (fd != i) { + if (fd != -1) + (void)close(fd); + // Something went wrong. Exit with the // exit status we were given. Don't try // to print an error message, since stderr // may very well be non-existent. This // error should be extremely rare. - (void)close(fd); exit(err_status); } }