index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Allan McRae <allan@archlinux.org> | 2011-01-29 11:39:25 +1000 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2011-02-04 09:55:45 +1000 |
commit | d843c86b7b7cbf376716817e7c2c55b1f9360a72 (patch) | |
tree | 0f1d6d7501333df041871781c0b24faadc8200e6 /lib/libalpm/pkghash.c | |
parent | 021085624ea94a7116c60552e5c153de6cb5f057 (diff) |
-rw-r--r-- | lib/libalpm/pkghash.c | 12 |
diff --git a/lib/libalpm/pkghash.c b/lib/libalpm/pkghash.c index f2497070..0324465f 100644 --- a/lib/libalpm/pkghash.c +++ b/lib/libalpm/pkghash.c @@ -59,6 +59,7 @@ pmpkghash_t *_alpm_pkghash_create(size_t size) hash->list = NULL; hash->entries = 0; + hash->buckets = 0; loopsize = sizeof(prime_list) / sizeof(*prime_list); for(i = 0; i < loopsize; i++) { @@ -68,6 +69,12 @@ pmpkghash_t *_alpm_pkghash_create(size_t size) } } + if(hash->buckets < size) { + _alpm_log(PM_LOG_ERROR, _("database larger than maximum size")); + free(hash); + return(NULL); + } + CALLOC(hash->hash_table, hash->buckets, sizeof(alpm_list_t*), \ free(hash); RET_ERR(PM_ERR_MEMORY, NULL)); @@ -98,6 +105,11 @@ static pmpkghash_t *rehash(pmpkghash_t *oldhash) } newhash = _alpm_pkghash_create(newsize); + if(newhash == NULL) { + /* creation of newhash failed, stick with old one... */ + return(oldhash); + } + for(ptr = oldhash->list; ptr != NULL; ptr = ptr->next) { newhash = _alpm_pkghash_add(newhash, ptr->data); } |