repo: fix a double free with invalid repodata.
Fixes #248 Added new test case to verify.
This commit is contained in:
@@ -156,7 +156,6 @@ repo_open_local(struct xbps_repo *repo, const char *repofile)
|
||||
xbps_dbg_printf(repo->xhp,
|
||||
"[repo] `%s' failed to open repodata archive %s\n",
|
||||
repofile, strerror(rv));
|
||||
xbps_repo_close(repo);
|
||||
return false;
|
||||
}
|
||||
if ((repo->idx = repo_get_dict(repo)) == NULL) {
|
||||
@@ -164,7 +163,6 @@ repo_open_local(struct xbps_repo *repo, const char *repofile)
|
||||
" index on archive, removing file.\n", repofile);
|
||||
/* broken archive, remove it */
|
||||
(void)unlink(repofile);
|
||||
xbps_repo_close(repo);
|
||||
return false;
|
||||
}
|
||||
xbps_dictionary_make_immutable(repo->idx);
|
||||
@@ -368,7 +366,8 @@ xbps_repo_open(struct xbps_handle *xhp, const char *url)
|
||||
void
|
||||
xbps_repo_close(struct xbps_repo *repo)
|
||||
{
|
||||
assert(repo);
|
||||
if (!repo)
|
||||
return;
|
||||
|
||||
if (repo->ar != NULL)
|
||||
archive_read_finish(repo->ar);
|
||||
|
Reference in New Issue
Block a user