This commit is contained in:
VilhoRaatikka
2014-10-30 18:20:54 +02:00
2 changed files with 8 additions and 1 deletions

View File

@ -902,8 +902,10 @@ static void *uh_keydup(void* key) {
rval->user = strdup(current_key->user);
if (rval->user == NULL)
if (rval->user == NULL) {
free(rval);
return NULL;
}
memcpy(&rval->ipv4, &current_key->ipv4, sizeof(struct sockaddr_in));
memcpy(&rval->netmask, &current_key->netmask, sizeof(int));

View File

@ -258,7 +258,9 @@ hashtable_add(HASHTABLE *table, void *key, void *value)
/* check succesfull key copy */
if ( ptr->key == NULL) {
free(ptr);
hashtable_write_unlock(table);
return 0;
}
@ -269,9 +271,11 @@ hashtable_add(HASHTABLE *table, void *key, void *value)
if ( ptr->value == NULL) {
/* remove the key ! */
table->kfreefn(ptr->key);
free(ptr);
/* value not copied, return */
hashtable_write_unlock(table);
return 0;
}
@ -279,6 +283,7 @@ hashtable_add(HASHTABLE *table, void *key, void *value)
table->entries[hashkey % table->hashsize] = ptr;
}
hashtable_write_unlock(table);
return 1;
}