FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 03-07-2009, 03:10 AM
 
Default Fixed a memory leak when unresolved packages are removed from transaction

From: Bryan Ischo <bji-keyword-pacman.3644cb@www.ischo.com>

Signed-off-by: Bryan Ischo <bji-keyword-pacman.3644cb@www.ischo.com>
---
lib/libalpm/sync.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index fca96d8..fe4eded 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -431,7 +431,10 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
}

/* Resolve packages in the transaction one at a time, in addtion
- building up a list of packages which could not be resolved. */
+ building up a list of packages which could not be resolved.
+ The list which is created by this loop is used later to replace
+ trans->packages; the unresolvable packages which were in the old
+ trans->packages list but not in the new list are freed up later. */
for(i = trans->packages; i; i = i->next) {
pmpkg_t *pkg = ((pmsyncpkg_t *) i->data)->pkg;
if(_alpm_resolvedeps(db_local, dbs_sync, pkg, &list, remove, data) == -1) {
@@ -500,6 +503,22 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
}
}
alpm_list_free(sortlist);
+
+ /* Destroy all packages which are in trans->packages but not in
+ newpkgs before replacing trans->packages with newpkgs */
+ for(i = trans->packages; i; i = i->next) {
+ pmsyncpkg_t *spkg = (pmsyncpkg_t *) i->data;
+ for (j = newpkgs; j; j = j->next) {
+ if(_alpm_pkg_cmp(spkg->pkg, ((pmsyncpkg_t *) j->data)->pkg) == 0) {
+ spkg = NULL;
+ break;
+ }
+ }
+ if (spkg != NULL) {
+ _alpm_sync_free(spkg);
+ }
+ }
+
alpm_list_free(trans->packages);
trans->packages = newpkgs;

--
1.6.1.3

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://www.archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 05:00 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org