From: Jim Meyering Date: Tue, 20 Dec 2005 10:24:37 +0000 (+0000) Subject: (fchmod_new): Don't try to close fd if it's < 0. X-Git-Tag: v6.0~1064 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7be64dd68fb5b5565cddc2a2b8f8b615f108ea80;p=thirdparty%2Fcoreutils.git (fchmod_new): Don't try to close fd if it's < 0. --- diff --git a/lib/chmod-safer.c b/lib/chmod-safer.c index 995efdc366..218a11448c 100644 --- a/lib/chmod-safer.c +++ b/lib/chmod-safer.c @@ -91,7 +91,7 @@ fchmod_new (char const *file, mode_t mode, dev_t device, mode_t file_type) saved_errno = errno; } - if (close (fd) != 0 && saved_errno == 0) + if (0 <= fd && close (fd) != 0 && saved_errno == 0) saved_errno = errno; errno = saved_errno;