From: Timo Sirainen Date: Mon, 1 Sep 2008 14:07:37 +0000 (+0300) Subject: hash2_remove_iter() was broken when it resized the hash table. X-Git-Tag: 1.2.alpha1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6206654569994e2d34cb36bb7d4da52a1bd66de3;p=thirdparty%2Fdovecot%2Fcore.git hash2_remove_iter() was broken when it resized the hash table. --HG-- branch : HEAD --- diff --git a/src/lib/hash2.c b/src/lib/hash2.c index bcf1eacc88..016747b949 100644 --- a/src/lib/hash2.c +++ b/src/lib/hash2.c @@ -186,13 +186,13 @@ void *hash2_insert_hash(struct hash2_table *hash, unsigned int key_hash) static void hash2_remove_value_p(struct hash2_table *hash, struct hash2_value **valuep) { - struct hash2_value *value; + struct hash2_value *deleted_value; - value = *valuep; - *valuep = value->next; + deleted_value = *valuep; + *valuep = deleted_value->next; - value->next = hash->deleted_values; - hash->deleted_values = value; + deleted_value->next = hash->deleted_values; + hash->deleted_values = deleted_value; hash->count--; hash2_resize(hash, FALSE); @@ -218,14 +218,15 @@ void hash2_remove(struct hash2_table *hash, const void *key) void hash2_remove_iter(struct hash2_table *hash, struct hash2_iter *iter) { - struct hash2_value **valuep; + struct hash2_value **valuep, *next; valuep = array_idx_modifiable(&hash->hash_table, iter->key_hash % hash->hash_table_size); while (*valuep != NULL) { if (*valuep == iter->value) { + next = (*valuep)->next; hash2_remove_value_p(hash, valuep); - iter->next_value = *valuep; + iter->next_value = next; return; } valuep = &(*valuep)->next;