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:
parent
ef1c514489
commit
bc6fe8f6ef
@ -167,9 +167,14 @@ hashtable_memory_fns(HASHTABLE *table, HASHMEMORYFN copyfn, HASHMEMORYFN freefn)
|
||||
int
|
||||
hashtable_add(HASHTABLE *table, void *key, void *value)
|
||||
{
|
||||
int hashkey = table->hashfn(key) % table->hashsize;
|
||||
HASHENTRIES *entry;
|
||||
int hashkey;
|
||||
HASHENTRIES *entry;
|
||||
|
||||
if (table->hashsize <= 0) {
|
||||
return 0;
|
||||
} else {
|
||||
hashkey = table->hashfn(key) % table->hashsize;
|
||||
}
|
||||
hashtable_write_lock(table);
|
||||
entry = table->entries[hashkey % table->hashsize];
|
||||
while (entry && table->cmpfn(key, entry->key) != 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user