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();