summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}