diff options
Diffstat (limited to 'lib/libalpm/db.c')
-rw-r--r-- | lib/libalpm/db.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 26e351fd..fe208be0 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -1,7 +1,7 @@ /* * db.c * - * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org> + * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu> @@ -331,7 +331,7 @@ alpm_db_t *_alpm_db_new(const char *treename, int is_local) alpm_db_t *db; CALLOC(db, 1, sizeof(alpm_db_t), return NULL); - STRDUP(db->treename, treename, return NULL); + STRDUP(db->treename, treename, FREE(db); return NULL); if(is_local) { db->status |= DB_STATUS_LOCAL; } else { @@ -542,7 +542,10 @@ alpm_pkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db) } if(!(db->status & DB_STATUS_PKGCACHE)) { - load_pkgcache(db); + if(load_pkgcache(db)) { + /* handle->error set in local/sync-db-populate */ + return NULL; + } } return db->pkgcache; @@ -562,13 +565,15 @@ alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db) /* "duplicate" pkg then add it to pkgcache */ int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg) { - alpm_pkg_t *newpkg; + alpm_pkg_t *newpkg = NULL; if(db == NULL || pkg == NULL || !(db->status & DB_STATUS_PKGCACHE)) { return -1; } if(_alpm_pkg_dup(pkg, &newpkg)) { + /* we return memory on "non-fatal" error in _alpm_pkg_dup */ + _alpm_pkg_free(newpkg); return -1; } |