From e39d05b31b67c9cbc3379d44751fb6f3403c3911 Mon Sep 17 00:00:00 2001 From: Aurelien Foret Date: Sat, 26 Mar 2005 21:20:03 +0000 Subject: - fixed a small memory leak - took into account sliptdep returned value --- lib/libalpm/remove.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 10e89b18..8f778576 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -146,7 +146,6 @@ int remove_commit(pmdb_t *db, pmtrans_t *trans) /* iterate through the list backwards, unlinking files */ for(lp = pm_list_last(info->files); lp; lp = lp->prev) { - char *newpath = NULL; int nb = 0; char *file = lp->data; if(_alpm_needbackup(lp->data, info->backup)) { @@ -175,8 +174,8 @@ int remove_commit(pmdb_t *db, pmtrans_t *trans) /* we're upgrading so just leave the file as is. pacman_add() will handle it */ } else { if(!(trans->flags & PM_TRANS_FLAG_NOSAVE)) { - newpath = (char*)realloc(newpath, strlen(line)+strlen(".pacsave")+1); - sprintf(newpath, "%s.pacsave", line); + char newpath[PATH_MAX]; + snprintf(newpath, PATH_MAX, "%s.pacsave", line); rename(line, newpath); _alpm_log(PM_LOG_WARNING, "%s saved as %s", file, newpath); alpm_logaction("%s saved as %s", line, newpath); @@ -212,6 +211,7 @@ int remove_commit(pmdb_t *db, pmtrans_t *trans) _alpm_log(PM_LOG_ERROR, "failed to remove database entry %s/%s-%s", db->treename, info->name, info->version); } + /* update dependency packages' REQUIREDBY fields */ _alpm_log(PM_LOG_FLOW2, "updating dependency packages 'requiredby' fields"); for(lp = info->depends; lp; lp = lp->next) { @@ -219,7 +219,9 @@ int remove_commit(pmdb_t *db, pmtrans_t *trans) pmpkg_t *depinfo = NULL; pmdepend_t depend; - splitdep((char*)lp->data, &depend); + if(splitdep((char*)lp->data, &depend)) { + continue; + } depinfo = db_scan(db, depend.name, INFRQ_DESC|INFRQ_DEPENDS); if(depinfo == NULL) { -- cgit v1.2.3-70-g09d2