summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-02-28 11:04:18 +0000
committerJim Meyering <jim@meyering.net>2003-02-28 11:04:18 +0000
commitfb428bedfcd04805bd81029f054ac3eb07c8282a (patch)
tree6225b557b7f3cc4d9e640007d131ccedcc093de8
parent9fef9aa3ebb24ad2f1db41ca6d1c71883c93ef87 (diff)
downloadcoreutils-fb428bedfcd04805bd81029f054ac3eb07c8282a.tar.xz
(fts_children): If fchdir fails, close file descriptor
before returning. From NetBSD.
-rw-r--r--lib/fts.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/fts.c b/lib/fts.c
index e917706c4..439826cfd 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -672,8 +672,10 @@ fts_children(sp, instr)
if ((fd = open(".", O_RDONLY, 0)) < 0)
return (NULL);
sp->fts_child = fts_build(sp, instr);
- if (fchdir(fd))
+ if (fchdir(fd)) {
+ (void)close(fd);
return (NULL);
+ }
(void)close(fd);
return (sp->fts_child);
}