diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2011-05-28 16:43:26 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2011-05-28 16:43:26 +0300 |
commit | fc4d4436969bd4d71b704d400a165875e596034a (patch) | |
tree | 2427970a19599a20c301e95bb9ad195f6ae2ee5f | |
parent | liblzma: Use symbol versioning. (diff) | |
download | xz-fc4d4436969bd4d71b704d400a165875e596034a.tar.xz |
Don't call close(-1) in tuklib_open_stdxxx() on error.
Thanks to Jim Meyering.
-rw-r--r-- | src/common/tuklib_open_stdxxx.c | 4 |
1 files changed, 3 insertions, 1 deletions
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); } } |