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 <dan@archlinux.org>
This commit is contained in:
Dan McGee 2008-03-23 15:28:48 -05:00
parent 7995a25d0e
commit 1086950c82
2 changed files with 4 additions and 0 deletions

View File

@ -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",

View File

@ -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);
}