From 7be64dd68fb5b5565cddc2a2b8f8b615f108ea80 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 20 Dec 2005 10:24:37 +0000 Subject: (fchmod_new): Don't try to close fd if it's < 0. --- lib/chmod-safer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/chmod-safer.c b/lib/chmod-safer.c index 995efdc36..218a11448 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; -- cgit v1.2.3-70-g09d2