summaryrefslogtreecommitdiff
path: root/lib/libalpm/db.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/db.c')
-rw-r--r--lib/libalpm/db.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 466c96f1..ebcd1f89 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -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;
}