summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-09-27 16:17:16 +0200
committerSebastien Helleu <flashcode@flashtux.org>2010-09-27 16:17:16 +0200
commitccd6a81f0b068109ae25b3b03e4d7622eccb8552 (patch)
tree4cf88e7ba1c04063b16058365e1e29b5ca9f6276 /src
parentbd7ae6d5a79991d7f65bc12091b61bcdc4bc5b49 (diff)
downloadweechat-ccd6a81f0b068109ae25b3b03e4d7622eccb8552.zip
Fix memory leak when removing item in hashtable
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-hashtable.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/wee-hashtable.c b/src/core/wee-hashtable.c
index 0f4d91601..24476e402 100644
--- a/src/core/wee-hashtable.c
+++ b/src/core/wee-hashtable.c
@@ -514,6 +514,8 @@ hashtable_remove_item (struct t_hashtable *hashtable,
if (hashtable->htable[hash] == item)
hashtable->htable[hash] = item->next_item;
+ free (item);
+
hashtable->items_count--;
}
@@ -527,6 +529,9 @@ hashtable_remove (struct t_hashtable *hashtable, const void *key)
struct t_hashtable_item *ptr_item;
unsigned int hash;
+ if (!hashtable || !key)
+ return;
+
ptr_item = hashtable_get_item (hashtable, key, &hash);
if (ptr_item)
hashtable_remove_item (hashtable, ptr_item, hash);
@@ -560,6 +565,9 @@ hashtable_remove_all (struct t_hashtable *hashtable)
void
hashtable_free (struct t_hashtable *hashtable)
{
+ if (!hashtable)
+ return;
+
hashtable_remove_all (hashtable);
free (hashtable->htable);
free (hashtable);