util/hash_table: don't compare deleted entries
authorConnor Abbott <cwabbott0@gmail.com>
Sun, 15 Nov 2015 01:24:31 +0000 (20:24 -0500)
committerConnor Abbott <cwabbott0@gmail.com>
Tue, 2 Feb 2016 19:42:40 +0000 (14:42 -0500)
The equivalent of the last patch for the hash table. I'm not aware of
any issues this fixes.

v2:
- use entry_is_deleted (Timothy)

Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Signed-off-by: Connor Abbott <cwabbott0@gmail.com>
src/util/hash_table.c

index 3247593c1f6c2747cd4723518e4e5b485f4889d2..3ec65afd4bb43b3e55c34564ff6641dc3fb2cc05 100644 (file)
@@ -300,7 +300,8 @@ hash_table_insert(struct hash_table *ht, uint32_t hash,
        * required to avoid memory leaks, perform a search
        * before inserting.
        */
-      if (entry->hash == hash &&
+      if (!entry_is_deleted(ht, entry) &&
+          entry->hash == hash &&
           ht->key_equals_function(key, entry->key)) {
          entry->key = key;
          entry->data = data;