mirror of
https://github.com/weechat/weechat.git
synced 2026-07-02 07:46:38 +02:00
Fix memory leak when removing item in hashtable
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user