From e6028f25f4a6860eebd420ba6ee87bf2e3b45ee9 Mon Sep 17 00:00:00 2001 From: RandyGaul Date: Tue, 8 Nov 2022 14:47:09 -0800 Subject: [PATCH] Infinite loop in hashtable_remove --- hashtable.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hashtable.h b/hashtable.h index 5016551..6eeaf92 100644 --- a/hashtable.h +++ b/hashtable.h @@ -709,12 +709,11 @@ void hashtable_remove( hashtable_t* table, HASHTABLE_U32 hash, void const* key ) HASHTABLE_U32 slot_capacity = (HASHTABLE_U32) table->slot_capacity; int const base_slot = (int)( hash % slot_capacity ); - HASHTABLE_ASSERT( hash ); + int index = table->slots[ slot ].item_index; + int last_index = table->count - 1; --table->slots[ base_slot ].base_count; table->slots[ slot ].item_index = -1; - int index = table->slots[ slot ].item_index; - int last_index = table->count - 1; if( index != last_index ) { void* dst_key = (void*)( ( (uintptr_t) table->items_key ) + index * table->key_size );