From 3d10786394f5b2a65104fdff3d31d70022dfd68d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 17 Nov 2007 09:39:00 -0600 Subject: Fix memleak in _alpm_trans_free with package lists Signed-off-by: Dan McGee --- lib/libalpm/trans.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lib/libalpm/trans.c') diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index f740472d..66a9ce33 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -247,6 +247,8 @@ pmtrans_t *_alpm_trans_new() void _alpm_trans_free(pmtrans_t *trans) { + alpm_list_t *i; + ALPM_LOG_FUNC; if(trans == NULL) { @@ -255,20 +257,15 @@ void _alpm_trans_free(pmtrans_t *trans) FREELIST(trans->targets); if(trans->type == PM_TRANS_TYPE_SYNC) { - alpm_list_t *i; for(i = trans->packages; i; i = alpm_list_next(i)) { _alpm_sync_free(i->data); - i->data = NULL; } - FREELIST(trans->packages); } else { - alpm_list_t *tmp; - for(tmp = trans->packages; tmp; tmp = alpm_list_next(tmp)) { - _alpm_pkg_free(tmp->data); - tmp->data = NULL; + for(i = trans->packages; i; i = alpm_list_next(i)) { + _alpm_pkg_free(i->data); } } - trans->packages = NULL; + alpm_list_free(trans->packages); FREELIST(trans->skip_add); FREELIST(trans->skip_remove); -- cgit v1.2.3-24-g4f1b