summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-04-26 20:03:53 +0200
committerDan McGee <dan@archlinux.org>2008-04-26 20:03:53 +0200
commit6d79ba2db0f37f46b925a509ef83724fc0f61184 (patch)
tree14b29d2d69c92f51e1c36ff0386503ce6046f6ca /lib/libalpm
parent481c3edc89fa674f9723c13ab4d12f032cf8ca02 (diff)
downloadpacman-6d79ba2db0f37f46b925a509ef83724fc0f61184.tar.gz
pacman-6d79ba2db0f37f46b925a509ef83724fc0f61184.tar.xz
Fix some fallout from the delta/download changes
We removed one too many FREELIST() calls when trying to fix some memleaks, and add a safety/sanity check to ensure filename is set, as packages in old DBs are likely to not have this field. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/error.c2
-rw-r--r--lib/libalpm/sync.c18
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c
index 7c30cd09..05caf8ec 100644
--- a/lib/libalpm/error.c
+++ b/lib/libalpm/error.c
@@ -120,7 +120,7 @@ const char SYMEXPORT *alpm_strerror(int err)
case PM_ERR_PKG_CANT_REMOVE:
return _("cannot remove all files for package");
case PM_ERR_PKG_INVALID_NAME:
- return _("package name is not valid");
+ return _("package filename is not valid");
case PM_ERR_PKG_REPO_NOT_FOUND:
return _("no such repository");
/* Deltas */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 9d087d7e..357b01f2 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -384,11 +384,16 @@ static int syncpkg_cmp(const void *s1, const void *s2)
* package.
* @param newpkg the new package to upgrade to
*/
-static void compute_download_size(pmpkg_t *newpkg)
+static int compute_download_size(pmpkg_t *newpkg)
{
- char *fpath = _alpm_filecache_find(alpm_pkg_get_filename(newpkg));
+ const char *fname;
+ char *fpath;
unsigned long size = 0;
+ fname = alpm_pkg_get_filename(newpkg);
+ ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1));
+ fpath = _alpm_filecache_find(fname);
+
if(fpath) {
FREE(fpath);
size = 0;
@@ -415,10 +420,11 @@ static void compute_download_size(pmpkg_t *newpkg)
size = alpm_pkg_get_size(newpkg);
}
- _alpm_log(PM_LOG_DEBUG, "returning size %ld for pkg %s\n", size,
+ _alpm_log(PM_LOG_DEBUG, "setting download size %ld for pkg %s\n", size,
alpm_pkg_get_name(newpkg));
newpkg->download_size = size;
+ return(0);
}
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data)
@@ -645,7 +651,10 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
for(i = list; i; i = i->next) {
/* update download size field */
pmpkg_t *spkg = i->data;
- compute_download_size(spkg);
+ if(compute_download_size(spkg) != 0) {
+ ret = -1;
+ goto cleanup;
+ }
}
cleanup:
@@ -859,6 +868,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
pm_errno = PM_ERR_RETRIEVE;
goto error;
}
+ FREELIST(files);
}
}
if(trans->flags & PM_TRANS_FLAG_PRINTURIS) {