From bb726ef20bacbea366079fb7af54245061a270bc Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 30 Mar 2003 15:02:55 +0000 Subject: [PATCH] (is_empty_dir): Don't let a failing closedir clobber errno. Spotted by Arnold Robbins. --- src/remove.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/remove.c b/src/remove.c index a0ad0a124..21c5ac0ac 100644 --- a/src/remove.c +++ b/src/remove.c @@ -527,8 +527,9 @@ is_empty_dir (char const *dir) dp = readdir (dirp); if (dp == NULL) { + int saved_errno = errno; closedir (dirp); - return errno == 0 ? true : false; + return saved_errno == 0 ? true : false; } f = dp->d_name; -- 2.34.1