deps.c: remove filtered_depend functions
filtered_dep was duplicating an alpm_depend_t solely for the purpose of overriding its depmod and would effectively cause alpm_checkdeps to ignore ALPM_TRANS_FLAG_NODEPVERSION if the duplication failed. Manually overriding/restoring the depmod for the original depend removes the duplication as a point of failure and fixes a memory leak where the duplicated depend was not being properly freed. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
6a656c7429
commit
6f468c2465
1 changed files with 10 additions and 22 deletions
|
@ -276,24 +276,6 @@ static int no_dep_version(alpm_handle_t *handle)
|
||||||
return (handle->trans->flags & ALPM_TRANS_FLAG_NODEPVERSION);
|
return (handle->trans->flags & ALPM_TRANS_FLAG_NODEPVERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
static alpm_depend_t *filtered_depend(alpm_depend_t *dep, int nodepversion)
|
|
||||||
{
|
|
||||||
if(nodepversion) {
|
|
||||||
alpm_depend_t *newdep = _alpm_dep_dup(dep);
|
|
||||||
ASSERT(newdep, return dep);
|
|
||||||
newdep->mod = ALPM_DEP_MOD_ANY;
|
|
||||||
dep = newdep;
|
|
||||||
}
|
|
||||||
return dep;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void release_filtered_depend(alpm_depend_t *dep, int nodepversion)
|
|
||||||
{
|
|
||||||
if(nodepversion) {
|
|
||||||
free(dep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Find a package satisfying a specified dependency.
|
/** Find a package satisfying a specified dependency.
|
||||||
* The dependency can include versions with depmod operators.
|
* The dependency can include versions with depmod operators.
|
||||||
* @param pkgs an alpm_list_t* of alpm_pkg_t where the satisfier will be searched
|
* @param pkgs an alpm_list_t* of alpm_pkg_t where the satisfier will be searched
|
||||||
|
@ -350,7 +332,10 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_handle_t *handle,
|
||||||
|
|
||||||
for(j = alpm_pkg_get_depends(tp); j; j = j->next) {
|
for(j = alpm_pkg_get_depends(tp); j; j = j->next) {
|
||||||
alpm_depend_t *depend = j->data;
|
alpm_depend_t *depend = j->data;
|
||||||
depend = filtered_depend(depend, nodepversion);
|
alpm_depmod_t orig_mod = depend->mod;
|
||||||
|
if(nodepversion) {
|
||||||
|
depend->mod = ALPM_DEP_MOD_ANY;
|
||||||
|
}
|
||||||
/* 1. we check the upgrade list */
|
/* 1. we check the upgrade list */
|
||||||
/* 2. we check database for untouched satisfying packages */
|
/* 2. we check database for untouched satisfying packages */
|
||||||
if(!find_dep_satisfier(upgrade, depend) &&
|
if(!find_dep_satisfier(upgrade, depend) &&
|
||||||
|
@ -364,7 +349,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_handle_t *handle,
|
||||||
miss = depmiss_new(tp->name, depend, NULL);
|
miss = depmiss_new(tp->name, depend, NULL);
|
||||||
baddeps = alpm_list_add(baddeps, miss);
|
baddeps = alpm_list_add(baddeps, miss);
|
||||||
}
|
}
|
||||||
release_filtered_depend(depend, nodepversion);
|
depend->mod = orig_mod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +360,10 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_handle_t *handle,
|
||||||
alpm_pkg_t *lp = i->data;
|
alpm_pkg_t *lp = i->data;
|
||||||
for(j = alpm_pkg_get_depends(lp); j; j = j->next) {
|
for(j = alpm_pkg_get_depends(lp); j; j = j->next) {
|
||||||
alpm_depend_t *depend = j->data;
|
alpm_depend_t *depend = j->data;
|
||||||
depend = filtered_depend(depend, nodepversion);
|
alpm_depmod_t orig_mod = depend->mod;
|
||||||
|
if(nodepversion) {
|
||||||
|
depend->mod = ALPM_DEP_MOD_ANY;
|
||||||
|
}
|
||||||
alpm_pkg_t *causingpkg = find_dep_satisfier(modified, depend);
|
alpm_pkg_t *causingpkg = find_dep_satisfier(modified, depend);
|
||||||
/* we won't break this depend, if it is already broken, we ignore it */
|
/* we won't break this depend, if it is already broken, we ignore it */
|
||||||
/* 1. check upgrade list for satisfiers */
|
/* 1. check upgrade list for satisfiers */
|
||||||
|
@ -391,7 +379,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_handle_t *handle,
|
||||||
miss = depmiss_new(lp->name, depend, causingpkg->name);
|
miss = depmiss_new(lp->name, depend, causingpkg->name);
|
||||||
baddeps = alpm_list_add(baddeps, miss);
|
baddeps = alpm_list_add(baddeps, miss);
|
||||||
}
|
}
|
||||||
release_filtered_depend(depend, nodepversion);
|
depend->mod = orig_mod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue