xbps-rindex/remove-obsoletes.c: fix CID 284947 (Resource leak).
This commit is contained in:
parent
e155ba6d20
commit
213ce1a72b
@ -131,16 +131,14 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
|||||||
if (chdir(repodir) == -1) {
|
if (chdir(repodir) == -1) {
|
||||||
fprintf(stderr, "xbps-rindex: cannot chdir to %s: %s\n",
|
fprintf(stderr, "xbps-rindex: cannot chdir to %s: %s\n",
|
||||||
repodir, strerror(errno));
|
repodir, strerror(errno));
|
||||||
free(repo);
|
rv = errno;
|
||||||
if(stage)
|
goto out;
|
||||||
free(stage);
|
|
||||||
return errno;
|
|
||||||
}
|
}
|
||||||
if ((dirp = opendir(repodir)) == NULL) {
|
if ((dirp = opendir(repodir)) == NULL) {
|
||||||
fprintf(stderr, "xbps-rindex: failed to open %s: %s\n",
|
fprintf(stderr, "xbps-rindex: failed to open %s: %s\n",
|
||||||
repodir, strerror(errno));
|
repodir, strerror(errno));
|
||||||
free(repo);
|
rv = errno;
|
||||||
return errno;
|
goto out;
|
||||||
}
|
}
|
||||||
while ((dp = readdir(dirp))) {
|
while ((dp = readdir(dirp))) {
|
||||||
if (strcmp(dp->d_name, "..") == 0)
|
if (strcmp(dp->d_name, "..") == 0)
|
||||||
@ -159,9 +157,9 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
|||||||
repos[0] = repo;
|
repos[0] = repo;
|
||||||
repos[1] = stage;
|
repos[1] = stage;
|
||||||
rv = xbps_array_foreach_cb_multi(xhp, array, NULL, cleaner_cb, repos);
|
rv = xbps_array_foreach_cb_multi(xhp, array, NULL, cleaner_cb, repos);
|
||||||
|
out:
|
||||||
xbps_repo_release(repo);
|
xbps_repo_release(repo);
|
||||||
if(stage)
|
xbps_repo_release(stage);
|
||||||
xbps_repo_release(stage);
|
|
||||||
xbps_object_release(array);
|
xbps_object_release(array);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
Loading…
Reference in New Issue
Block a user