[pacman-dev] [PATCH 1/8] avoid double freeing unresolvable packages

Andrew Gregory andrew.gregory.8 at gmail.com
Mon Jan 6 11:52:20 EST 2014


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 at gmail.com>
---
 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);
-- 
1.8.5.2



More information about the pacman-dev mailing list