summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bftw.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bftw.c b/bftw.c
index d489bc8..5630109 100644
--- a/bftw.c
+++ b/bftw.c
@@ -234,7 +234,11 @@ static DIR *opendirat(int fd, const char *name) {
return NULL;
}
- return fdopendir(dfd);
+ DIR *dir = fdopendir(dfd);
+ if (!dir) {
+ close(dfd);
+ }
+ return dir;
}
/**