summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-09-01 15:14:51 +0000
committerMark Johnston <markj@FreeBSD.org>2020-09-01 15:14:51 +0000
commitd4b748de1e50121f9ffaad1dc9486df0144a1d0e (patch)
tree2fa34b257edc667b54d63cfcc0665304ef9c0064
parent724a328b73087291a6f92c06edd19be0c8b2491f (diff)
downloadpw-darwin-d4b748de1e50121f9ffaad1dc9486df0144a1d0e.tar.gz
pw-darwin-d4b748de1e50121f9ffaad1dc9486df0144a1d0e.tar.zst
pw-darwin-d4b748de1e50121f9ffaad1dc9486df0144a1d0e.zip
pw: Fix a resource leak.
Reported by: Coverity MFC after: 1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc.
-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;