diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index 4db618fc..f9878ac3 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -305,6 +305,7 @@ omemo_on_disconnect(void) g_key_file_free(omemo_ctx.trust_keyfile); g_string_free(omemo_ctx.sessions_filename, TRUE); g_key_file_free(omemo_ctx.sessions_keyfile); + _g_hash_table_free(omemo_ctx.session_store); g_string_free(omemo_ctx.known_devices_filename, TRUE); g_key_file_free(omemo_ctx.known_devices_keyfile); } @@ -386,6 +387,7 @@ omemo_start_sessions(void) const char *jid = p_contact_barejid(contact); omemo_start_session(jid); } + g_slist_free(contacts); } } diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 1fbf2156..7238b9a1 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -203,6 +203,7 @@ _create_tab(const int win, win_type_t wintype, char *identifier, gboolean highli } else { tab->display_name = strdup(tab->identifier); } + prefs_free_string(pref); } } @@ -452,21 +453,27 @@ _status_bar_draw_maintext(int pos) return; } + gboolean stop = FALSE; + if (statusbar->fulljid) { char *pref = prefs_get_string(PREF_STATUSBAR_SELF); + if (g_strcmp0(pref, "off") == 0) { - return; - } - if (g_strcmp0(pref, "user") == 0) { + stop = true; + } else if (g_strcmp0(pref, "user") == 0) { Jid *jidp = jid_create(statusbar->fulljid); mvwprintw(statusbar_win, 0, pos, jidp->localpart); jid_destroy(jidp); - return; - } - if (g_strcmp0(pref, "barejid") == 0) { + stop = true; + } else if (g_strcmp0(pref, "barejid") == 0) { Jid *jidp = jid_create(statusbar->fulljid); mvwprintw(statusbar_win, 0, pos, jidp->barejid); jid_destroy(jidp); + stop = true; + } + + prefs_free_string(pref); + if (stop) { return; } mvwprintw(statusbar_win, 0, pos, statusbar->fulljid); @@ -556,9 +563,11 @@ _display_name(StatusBarTab *tab) } else { fullname = strdup(tab->identifier); } + prefs_free_string(pref); } else if (tab->window_type == WIN_CONFIG) { char *pref = prefs_get_string(PREF_STATUSBAR_ROOM); GString *display_str = g_string_new(""); + if (g_strcmp0("room", pref) == 0) { Jid *jidp = jid_create(tab->identifier); g_string_append(display_str, jidp->localpart); @@ -566,6 +575,8 @@ _display_name(StatusBarTab *tab) } else { g_string_append(display_str, tab->identifier); } + + prefs_free_string(pref); g_string_append(display_str, " conf"); char *result = strdup(display_str->str); g_string_free(display_str, TRUE); @@ -585,6 +596,7 @@ _display_name(StatusBarTab *tab) } else { fullname = strdup(tab->identifier); } + prefs_free_string(pref); } else { fullname = strdup("window"); } diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c index 99c17c1e..89f1db78 100644 --- a/src/xmpp/bookmark.c +++ b/src/xmpp/bookmark.c @@ -318,14 +318,12 @@ _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata) static void _bookmark_destroy(Bookmark *bookmark) { - if (!bookmark) { - return; + if (bookmark) { + free(bookmark->barejid); + free(bookmark->nick); + free(bookmark->password); + free(bookmark); } - - free(bookmark->barejid); - free(bookmark->nick); - free(bookmark->password); - free(bookmark); } static void 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 @@ -251,6 +251,14 @@ iq_handlers_init(void) rooms_cache = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)xmpp_stanza_release); } +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) { diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 47cf35d7..9f0ffb2b 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -178,6 +178,14 @@ message_handlers_init(void) pubsub_event_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); } +void +message_handlers_clear(void) +{ + if (pubsub_event_handlers) { + g_hash_table_remove_all(pubsub_event_handlers); + } +} + void message_pubsub_event_handler_add(const char *const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void *userdata) { diff --git a/src/xmpp/message.h b/src/xmpp/message.h index 0c81ca39..a42644fd 100644 --- a/src/xmpp/message.h +++ b/src/xmpp/message.h @@ -39,6 +39,7 @@ typedef int(*ProfMessageCallback)(xmpp_stanza_t *const stanza, void *const userd typedef void(*ProfMessageFreeCallback)(void *userdata); void message_handlers_init(void); +void message_handlers_clear(void); void message_pubsub_event_handler_add(const char *const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void *userdata); #endif diff --git a/src/xmpp/session.c b/src/xmpp/session.c index b2b56695..1d873012 100644 --- a/src/xmpp/session.c +++ b/src/xmpp/session.c @@ -213,8 +213,10 @@ session_disconnect(void) accounts_set_last_activity(session_get_account_name()); iq_rooms_cache_clear(); + iq_handlers_clear(); connection_disconnect(); + message_handlers_clear(); connection_clear_data(); chat_sessions_clear(); 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); diff --git a/tests/unittests/test_cmd_otr.c b/tests/unittests/test_cmd_otr.c index ffb6f785..ec879ab4 100644 --- a/tests/unittests/test_cmd_otr.c +++ b/tests/unittests/test_cmd_otr.c @@ -59,6 +59,7 @@ void cmd_otr_log_on_enables_logging(void **state) assert_true(result); assert_string_equal("on", pref_otr_log); + prefs_free_string(pref_otr_log); } void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state) @@ -87,6 +88,7 @@ void cmd_otr_log_off_disables_logging(void **state) assert_true(result); assert_string_equal("off", pref_otr_log); + prefs_free_string(pref_otr_log); } void cmd_otr_redact_redacts_logging(void **state) @@ -102,6 +104,7 @@ void cmd_otr_redact_redacts_logging(void **state) assert_true(result); assert_string_equal("redact", pref_otr_log); + prefs_free_string(pref_otr_log); } void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state) diff --git a/tests/unittests/test_cmd_presence.c b/tests/unittests/test_cmd_presence.c index 74d4a132..54f69826 100644 --- a/tests/unittests/test_cmd_presence.c +++ b/tests/unittests/test_cmd_presence.c @@ -67,6 +67,7 @@ void cmd_presence_console_sets_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_console_sets_online(void **state) @@ -81,6 +82,7 @@ void cmd_presence_console_sets_online(void **state) assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_console_sets_none(void **state) @@ -95,6 +97,7 @@ void cmd_presence_console_sets_none(void **state) assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_chat_sets_all(void **state) @@ -109,6 +112,7 @@ void cmd_presence_chat_sets_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_chat_sets_online(void **state) @@ -123,6 +127,7 @@ void cmd_presence_chat_sets_online(void **state) assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_chat_sets_none(void **state) @@ -137,6 +142,7 @@ void cmd_presence_chat_sets_none(void **state) assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_room_sets_all(void **state) @@ -151,6 +157,7 @@ void cmd_presence_room_sets_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_room_sets_online(void **state) @@ -165,6 +172,7 @@ void cmd_presence_room_sets_online(void **state) assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_room_sets_none(void **state) @@ -179,4 +187,5 @@ void cmd_presence_room_sets_none(void **state) assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); + prefs_free_string(setting); } diff --git a/tests/unittests/test_preferences.c b/tests/unittests/test_preferences.c index c4bcbf77..05f34ca6 100644 --- a/tests/unittests/test_preferences.c +++ b/tests/unittests/test_preferences.c @@ -14,6 +14,7 @@ void statuses_console_defaults_to_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); + prefs_free_string(setting); } void statuses_chat_defaults_to_all(void **state) @@ -22,6 +23,7 @@ void statuses_chat_defaults_to_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); + prefs_free_string(setting); } void statuses_muc_defaults_to_all(void **state) @@ -30,4 +32,5 @@ void statuses_muc_defaults_to_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); + prefs_free_string(setting); }