about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/iq.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 91acc212..e31f3269 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -134,6 +134,7 @@ static int _command_exec_response_handler(xmpp_stanza_t *const stanza, void *con
 
 static void _iq_free_room_data(ProfRoomInfoData *roominfo);
 static void _iq_free_affiliation_set(ProfPrivilegeSet *affiliation_set);
+static void _iq_id_handler_free(ProfIqHandler *handler);
 
 // scheduled
 static int _autoping_timed_send(xmpp_conn_t *const conn, void *const userdata);
@@ -247,7 +248,7 @@ iq_handlers_init(void)
         g_list_free(keys);
         g_hash_table_destroy(id_handlers);
     }
-    id_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
+    id_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_iq_id_handler_free);
     rooms_cache = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)xmpp_stanza_release);
 }
 
@@ -259,6 +260,19 @@ iq_handlers_clear()
     }
 }
 
+static void
+_iq_id_handler_free(ProfIqHandler *handler)
+{
+    if (handler == NULL) {
+        return;
+    }
+    if (handler->free_func && handler->userdata) {
+        handler->free_func(handler->userdata);
+    }
+    free(handler);
+    handler = NULL;
+}
+
 void
 iq_id_handler_add(const char *const id, ProfIqCallback func, ProfIqFreeCallback free_func, void *userdata)
 {