--- src/util/non_replacing_hash_table.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/util/non_replacing_hash_table.c b/src/util/non_replacing_hash_table.c index 1128388ab8..48f42aa7c9 100644 --- a/src/util/non_replacing_hash_table.c +++ b/src/util/non_replacing_hash_table.c @@ -222,7 +222,23 @@ hash_table_search(struct hash_table *ht, uint32_t hash, const void *key) return NULL; } else if (entry_is_present(ht, entry) && entry->hash == hash) { if (ht->key_equals_function(key, entry->key)) { - return entry; + struct hash_entry *previous_entry = entry; + + /* Follow the chain of matching key's to the end */ + while (previous_entry->next_data != 0 ) { + entry = ht->table + previous_entry->next_data; + /* We might have deleted the last entry, and have a + * dangling reference, so check that the keys match + * before we continue on traversing through the chain. + * If the key's don't match we return the previous entry. + */ + if (!ht->key_equals_function(key, entry->key)) + return previous_entry; + + previous_entry = entry; + } + + return previous_entry; } } -- 2.11.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev