hashtable_add now checks input parameter and returns with zero (indicating that no elements were added) if hashsize is zero. Caused floating point exception.
This commit is contained in:
@ -167,9 +167,14 @@ hashtable_memory_fns(HASHTABLE *table, HASHMEMORYFN copyfn, HASHMEMORYFN freefn)
|
|||||||
int
|
int
|
||||||
hashtable_add(HASHTABLE *table, void *key, void *value)
|
hashtable_add(HASHTABLE *table, void *key, void *value)
|
||||||
{
|
{
|
||||||
int hashkey = table->hashfn(key) % table->hashsize;
|
int hashkey;
|
||||||
HASHENTRIES *entry;
|
HASHENTRIES *entry;
|
||||||
|
|
||||||
|
if (table->hashsize <= 0) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
hashkey = table->hashfn(key) % table->hashsize;
|
||||||
|
}
|
||||||
hashtable_write_lock(table);
|
hashtable_write_lock(table);
|
||||||
entry = table->entries[hashkey % table->hashsize];
|
entry = table->entries[hashkey % table->hashsize];
|
||||||
while (entry && table->cmpfn(key, entry->key) != 0)
|
while (entry && table->cmpfn(key, entry->key) != 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user