summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/be_local.c
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2018-01-08 01:30:42 +0100
committerAllan McRae <allan@archlinux.org>2018-01-10 01:52:26 +0100
commit2bda849bf9b39b423175d1ee1d8796b856cc9988 (patch)
tree457191f5eae040c3c37b152fe14dab275ff4c0af /lib/libalpm/be_local.c
parent59b6fdeee1722a58d1599bcbd1e2c0fc33debc99 (diff)
downloadpacman-2bda849bf9b39b423175d1ee1d8796b856cc9988.tar.gz
pacman-2bda849bf9b39b423175d1ee1d8796b856cc9988.tar.xz
detect pkghash allocation failure
If rehash ever failed with a full hash it would return the old hash that is already full. get_hash_position would then loop forever because it would never find an empty bucket. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_local.c')
-rw-r--r--lib/libalpm/be_local.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 97a49688..1ec6a20f 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -601,7 +601,10 @@ static int local_db_populate(alpm_db_t *db)
/* add to the collection */
_alpm_log(db->handle, ALPM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
pkg->name, db->treename);
- db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
+ if(_alpm_pkghash_add(&db->pkgcache, pkg) == NULL) {
+ _alpm_pkg_free(pkg);
+ RET_ERR(db->handle, ALPM_ERR_MEMORY, -1);
+ }
count++;
}