summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/core/wee-hashtable.c8
2 files changed, 9 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 063bffdc9..12d723db7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@ Version 0.3.4 (under dev!)
--------------------------
* core: add new option weechat.look.input_share (task #9228)
+* core: fix memory leak when removing item in hashtable
* core: use similar behaviour for keys bound to local or global history
(bug #30759)
* api: add priority for hooks (task #10550)
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);