summaryrefslogtreecommitdiff
path: root/mysys/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'mysys/hash.c')
-rw-r--r--mysys/hash.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/mysys/hash.c b/mysys/hash.c
index 347e0cfda8a..87d714d6148 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -116,17 +116,23 @@ my_hash_init2(PSI_memory_key psi_key, HASH *hash, uint growth_size,
static inline void my_hash_free_elements(HASH *hash)
{
uint records= hash->records;
+ if (records == 0)
+ return;
+
/*
Set records to 0 early to guard against anyone looking at the structure
during the free process
*/
hash->records= 0;
+
if (hash->free)
{
HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*);
HASH_LINK *end= data + records;
- while (data < end)
+ do
+ {
(*hash->free)((data++)->data);
+ } while (data < end);
}
}