diff options
author | James Booth <boothj5@gmail.com> | 2014-06-26 23:55:57 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-06-26 23:55:57 +0100 |
commit | c98ce4299de670dd5d270308bf7137ea05d9c763 (patch) | |
tree | 2ae9aaeddb6d7e63d2ce892a03cfcdd85b9bf253 | |
parent | 8cf7122e7a10352161450f3ca80b1b6e4738d7c1 (diff) | |
download | profani-tty-c98ce4299de670dd5d270308bf7137ea05d9c763.tar.gz |
Free resources on OTR shutdown
-rw-r--r-- | src/command/commands.c | 1 | ||||
-rw-r--r-- | src/otr/otr.c | 17 | ||||
-rw-r--r-- | src/otr/otr.h | 1 | ||||
-rw-r--r-- | src/profanity.c | 3 |
4 files changed, 20 insertions, 2 deletions
diff --git a/src/command/commands.c b/src/command/commands.c index f979da41..3e7dffd9 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2766,6 +2766,7 @@ cmd_otr(gchar **args, struct cmd_help_t help) if (strcmp(args[0], "gen") == 0) { ProfAccount *account = accounts_get_account(jabber_get_account_name()); otr_keygen(account); + account_free(account); return TRUE; } else if (strcmp(args[0], "myfp") == 0) { diff --git a/src/otr/otr.c b/src/otr/otr.c index b6b68dcd..c9280642 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -163,6 +163,14 @@ _otr_init(void) data_loaded = FALSE; } +static void +_otr_shutdown(void) +{ + if (jid != NULL) { + free(jid); + } +} + void _otr_poll(void) { @@ -172,6 +180,9 @@ _otr_poll(void) static void _otr_on_connect(ProfAccount *account) { + if (jid != NULL) { + free(jid); + } jid = strdup(account->jid); log_info("Loading OTR key for %s", jid); @@ -253,11 +264,12 @@ _otr_keygen(ProfAccount *account) return; } + if (jid != NULL) { + free(jid); + } jid = strdup(account->jid); log_info("Generating OTR key for %s", jid); - jid = strdup(account->jid); - gchar *data_home = xdg_get_data_home(); GString *basedir = g_string_new(data_home); free(data_home); @@ -634,6 +646,7 @@ void otr_init_module(void) { otr_init = _otr_init; + otr_shutdown = _otr_shutdown; otr_libotr_version = _otr_libotr_version; otr_start_query = _otr_start_query; otr_poll = _otr_poll; diff --git a/src/otr/otr.h b/src/otr/otr.h index a8553280..0df19f42 100644 --- a/src/otr/otr.h +++ b/src/otr/otr.h @@ -41,6 +41,7 @@ OtrlMessageAppOps* otr_messageops(void); GHashTable* otr_smpinitators(void); void (*otr_init)(void); +void (*otr_shutdown)(void); char* (*otr_libotr_version)(void); char* (*otr_start_query)(void); void (*otr_poll)(void); diff --git a/src/profanity.c b/src/profanity.c index bcf4f93c..1692fceb 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -305,6 +305,9 @@ _shutdown(void) muc_close(); caps_close(); ui_close(); +#ifdef HAVE_LIBOTR + otr_shutdown(); +#endif chat_log_close(); prefs_close(); theme_close(); |