pw: Fix a resource leak.

Reported by:	Coverity
MFC after:	1 week
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
This commit is contained in:
Mark Johnston 2020-09-01 15:14:51 +00:00
parent 45bfd3158c
commit 7a82cf511d

View File

@ -57,6 +57,10 @@ rm_r(int rootfd, const char *path, uid_t uid)
} }
d = fdopendir(dirfd); d = fdopendir(dirfd);
if (d == NULL) {
(void)close(dirfd);
return;
}
while ((e = readdir(d)) != NULL) { while ((e = readdir(d)) != NULL) {
if (strcmp(e->d_name, ".") == 0 || strcmp(e->d_name, "..") == 0) if (strcmp(e->d_name, ".") == 0 || strcmp(e->d_name, "..") == 0)
continue; continue;