diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2013-11-14 21:02:07 -0500 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2014-01-06 14:38:49 +1000 |
commit | 6f468c2465f4bfdcf4779c920899a960857c7361 (patch) | |
tree | e542a71075b0c135dc984805b6cbbcb7da99bb5c /lib/libalpm | |
parent | 6a656c7429c6fce44abf6f83657dd7b423979cd9 (diff) | |
download | pacman-6f468c2465f4bfdcf4779c920899a960857c7361.tar.xz |
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>
Diffstat (limited to 'lib/libalpm')
-rw-r--r-- | lib/libalpm/deps.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index e5a04047..6771eacf 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -276,24 +276,6 @@ static int no_dep_version(alpm_handle_t *handle) 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. * The dependency can include versions with depmod operators. * @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) { 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 */ /* 2. we check database for untouched satisfying packages */ 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); 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; for(j = alpm_pkg_get_depends(lp); j; j = j->next) { 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); /* we won't break this depend, if it is already broken, we ignore it */ /* 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); baddeps = alpm_list_add(baddeps, miss); } - release_filtered_depend(depend, nodepversion); + depend->mod = orig_mod; } } } |