From 3e02961ec8f21fd656c8b306c5075c0c799df97f Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 23 Feb 2020 17:23:47 +0000 Subject: [PATCH] utils: Fix destroy of non-empty hashmap Signed-off-by: Daniel Silverstone --- utils/hashmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/hashmap.c b/utils/hashmap.c index bfbf6ceb8..b7870a3a7 100644 --- a/utils/hashmap.c +++ b/utils/hashmap.c @@ -85,11 +85,12 @@ hashmap_destroy(hashmap_t *hashmap) for (bucket = 0; bucket < hashmap->bucket_count; bucket++) { for (entry = hashmap->buckets[bucket]; - entry != NULL; - entry = entry->next) { + entry != NULL;) { + hashmap_entry_t *next = entry->next; hashmap->params->value_destroy(entry->value); hashmap->params->key_destroy(entry->key); free(entry); + entry = next; } }