Skip to content

Commit a8d817c

Browse files
committed
bin/xbps-remove: fix DIR leak in --clean-cache
1 parent 4fc3610 commit a8d817c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

bin/xbps-remove/clean-cache.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,10 @@ clean_cachedir(struct xbps_handle *xhp, bool uninstalled, bool drun)
176176
}
177177

178178
array = xbps_array_create();
179-
if (!array)
179+
if (!array) {
180+
(void)closedir(dirp);
180181
return xbps_error_oom();
182+
}
181183

182184
while ((dp = readdir(dirp)) != NULL) {
183185
if ((strcmp(dp->d_name, ".") == 0) ||
@@ -193,6 +195,7 @@ clean_cachedir(struct xbps_handle *xhp, bool uninstalled, bool drun)
193195
}
194196
if (!xbps_array_add_cstring(array, dp->d_name)) {
195197
xbps_object_release(array);
198+
(void)closedir(dirp);
196199
return xbps_error_oom();
197200
}
198201
}

0 commit comments

Comments
 (0)