From 7995a25d0ed75968df72fcf65d231508417ec060 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 23 Mar 2008 15:16:31 -0500 Subject: strsplit(): memleak fix We dup-ed the string but then duped it again. Fix it. Signed-off-by: Dan McGee --- src/pacman/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index aa08eb26..0facfdd1 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -384,7 +384,7 @@ alpm_list_t *strsplit(const char *str, const char splitchar) if(dup == NULL) { return(NULL); } - list = alpm_list_add(list, strdup(prev)); + list = alpm_list_add(list, dup); return(list); } -- cgit v1.2.3-70-g09d2 From 1086950c82ab649ffc36a00cd8d343da376252fe Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 23 Mar 2008 15:28:48 -0500 Subject: memleak fix: ensure backup fname isn't lost if unused The _alpm_backup_split function always alloced memory for the fname, and we let it disappear in a specific case (upgrade026.py). Fix the issue. Signed-off-by: Dan McGee --- lib/libalpm/add.c | 1 + lib/libalpm/backup.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index eddf637e..8b06bef5 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -243,6 +243,7 @@ static int upgrade_remove(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *trans, pm char *backup = _alpm_backup_file(b->data); /* safety check (fix the upgrade026 pactest) */ if(!alpm_list_find_str(filelist, backup)) { + FREE(backup); continue; } _alpm_log(PM_LOG_DEBUG, "adding %s to the NoUpgrade array temporarily\n", diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c index bedbe8c1..f89df55e 100644 --- a/lib/libalpm/backup.c +++ b/lib/libalpm/backup.c @@ -42,6 +42,9 @@ int _alpm_backup_split(const char *string, char **file, char **hash) if(ptr == NULL) { if(file) { *file = str; + } else { + /* don't need our dup as the fname wasn't requested, so free it */ + FREE(str); } return(0); } -- cgit v1.2.3-70-g09d2