summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pw/rm_r.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/pw/rm_r.c b/pw/rm_r.c
index 66298a2..66ec3f2 100644
--- a/pw/rm_r.c
+++ b/pw/rm_r.c
@@ -57,6 +57,10 @@ rm_r(int rootfd, const char *path, uid_t uid)
}
d = fdopendir(dirfd);
+ if (d == NULL) {
+ (void)close(dirfd);
+ return;
+ }
while ((e = readdir(d)) != NULL) {
if (strcmp(e->d_name, ".") == 0 || strcmp(e->d_name, "..") == 0)
continue;