about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-06-19 23:37:54 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-06-20 12:37:32 +0200
commit11b8204d14af3777fe6c4083988ea8681354cb1c (patch)
tree2836b8d3e3cd3ab5848733aedfeac73377716cc9 /src
parent29e2d16e14f6019d2d8806c3232604b9617b0920 (diff)
downloadprofani-tty-11b8204d14af3777fe6c4083988ea8681354cb1c.tar.gz
Call iq_handlers_clear() upon disconnect
Free id_handlers. Fix memory leaks.
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/iq.c8
-rw-r--r--src/xmpp/session.c1
-rw-r--r--src/xmpp/xmpp.h1
3 files changed, 10 insertions, 0 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 24208244..91acc212 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -252,6 +252,14 @@ iq_handlers_init(void)
 }
 
 void
+iq_handlers_clear()
+{
+    if (id_handlers) {
+        g_hash_table_remove_all(id_handlers);
+    }
+}
+
+void
 iq_id_handler_add(const char *const id, ProfIqCallback func, ProfIqFreeCallback free_func, void *userdata)
 {
     ProfIqHandler *handler = malloc(sizeof(ProfIqHandler));
diff --git a/src/xmpp/session.c b/src/xmpp/session.c
index b2b56695..787dc0b3 100644
--- a/src/xmpp/session.c
+++ b/src/xmpp/session.c
@@ -213,6 +213,7 @@ session_disconnect(void)
         accounts_set_last_activity(session_get_account_name());
 
         iq_rooms_cache_clear();
+        iq_handlers_clear();
 
         connection_disconnect();
 
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index d04d88fd..ae6df097 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -169,6 +169,7 @@ void iq_enable_carbons(void);
 void iq_disable_carbons(void);
 void iq_send_software_version(const char *const fulljid);
 void iq_rooms_cache_clear(void);
+void iq_handlers_clear();
 void iq_room_list_request(gchar *conferencejid, gchar *filter);
 void iq_disco_info_request(gchar *jid);
 void iq_disco_items_request(gchar *jid);