dovecot-1.2: hash2_remove_iter() was broken when it resized the ...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Sep 1 17:07:42 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/7b5120f7f732
changeset: 8150:7b5120f7f732
user: Timo Sirainen <tss at iki.fi>
date: Mon Sep 01 17:07:37 2008 +0300
description:
hash2_remove_iter() was broken when it resized the hash table.
diffstat:
1 file changed, 10 insertions(+), 9 deletions(-)
src/lib/hash2.c | 19 ++++++++++---------
diffs (42 lines):
diff -r 17cec811c5fd -r 7b5120f7f732 src/lib/hash2.c
--- a/src/lib/hash2.c Mon Sep 01 16:10:27 2008 +0300
+++ b/src/lib/hash2.c Mon Sep 01 17:07:37 2008 +0300
@@ -186,13 +186,13 @@ static void hash2_remove_value_p(struct
static void hash2_remove_value_p(struct hash2_table *hash,
struct hash2_value **valuep)
{
- struct hash2_value *value;
-
- value = *valuep;
- *valuep = value->next;
-
- value->next = hash->deleted_values;
- hash->deleted_values = value;
+ struct hash2_value *deleted_value;
+
+ deleted_value = *valuep;
+ *valuep = deleted_value->next;
+
+ 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 *ha
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;
More information about the dovecot-cvs
mailing list