Work around segfault in otrl_userstate_free()
It only occurs when SSL is enabled and mcabber is linked to libgnutls.
Seems to be a problem in libgcrypt when both libotr and libgnutls use it.
--- a/mcabber/src/main.c Sun Sep 09 13:24:40 2007 +0200
+++ b/mcabber/src/main.c Sun Sep 09 17:44:34 2007 +0200
@@ -471,6 +471,7 @@
}
}
+ scr_TerminateCurses();
#ifdef HAVE_LIBOTR
otr_terminate();
#endif
@@ -478,7 +479,6 @@
#ifdef HAVE_GPGME
gpg_terminate();
#endif
- scr_TerminateCurses();
#ifdef HAVE_ASPELL_H
/* Deinitialize aspell */
if (settings_opt_get_int("aspell_enable")) {
--- a/mcabber/src/otr.c Sun Sep 09 13:24:40 2007 +0200
+++ b/mcabber/src/otr.c Sun Sep 09 17:44:34 2007 +0200
@@ -141,7 +141,18 @@
g_free(account);
account = NULL;
+
+ /* XXX This #ifdef is a quick workaround: when mcabber
+ * is linked to both gnutls and libotr, libgcrypt will
+ * segfault when we call otrl_userstate_free().
+ * This is reported to be a bug in libgcrypt :-/
+ * Mikael
+ */
+#if defined(HAVE_GNUTLS) && !defined(HAVE_OPENSSL)
+ if (!settings_opt_get_int("ssl"))
+#endif
otrl_userstate_free(userstate);
+
userstate = NULL;
g_free(keyfile);
keyfile = NULL;