]> granicus.if.org Git - xz/commitdiff
Don't call close(-1) in tuklib_open_stdxxx() on error.
authorLasse Collin <lasse.collin@tukaani.org>
Sat, 28 May 2011 13:43:26 +0000 (16:43 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Sat, 28 May 2011 15:54:42 +0000 (18:54 +0300)
Thanks to Jim Meyering.

src/common/tuklib_open_stdxxx.c

index 08bc60d8cf87c7bb1fb3bc73d2e82750f31df606..26702a6afab003c16b70cd31df91e29d254321f7 100644 (file)
@@ -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);
                        }
                }