]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
pw: Fix a resource leak.
authorMark Johnston <markj@FreeBSD.org>
Tue, 1 Sep 2020 15:14:51 +0000 (15:14 +0000)
committerMark Johnston <markj@FreeBSD.org>
Tue, 1 Sep 2020 15:14:51 +0000 (15:14 +0000)
Reported by: Coverity
MFC after: 1 week
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

pw/rm_r.c

index 66298a248f19d1c01ee2ce8e78f259c3985c53f8..66ec3f21423f2cd72ce92098034f256c794a6cc1 100644 (file)
--- 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;