On 07/01/14 02:52, Andrew Gregory wrote:
If an unresolvable package was loaded from a file it would be free'd again when freeing trans->add.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> ---
This patch I do not understand. Where does anything get added to trans->unresolvable that is not removed from trans->add?
lib/libalpm/trans.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index ada8100..4930e94 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -246,12 +246,19 @@ int SYMEXPORT alpm_trans_release(alpm_handle_t *handle)
void _alpm_trans_free(alpm_trans_t *trans) { + alpm_list_t *i; + if(trans == NULL) { return; }
- alpm_list_free_inner(trans->unresolvable, - (alpm_list_fn_free)_alpm_pkg_free_trans); + /* only free packages not in trans->add to avoid + * double free'ing packages loaded from files. */ + for(i = trans->unresolvable; i; i = i->next) { + if(!alpm_list_find_ptr(trans->add, i->data)) { + _alpm_pkg_free_trans(i->data); + } + } alpm_list_free(trans->unresolvable); alpm_list_free_inner(trans->add, (alpm_list_fn_free)_alpm_pkg_free_trans); alpm_list_free(trans->add);