[pkg-otr-team] [irssi-plugin-otr] 160/167: Be sure to clean up in the right order when unloading

Holger Levsen holger at moszumanska.debian.org
Mon Mar 3 21:55:41 UTC 2014


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to tag 4.0.0
in repository irssi-plugin-otr.

commit 91cc8116e47c48406c2923519a42470cc65c6d54
Author: Ian Goldberg <iang at cs.uwaterloo.ca>
Date:   Thu Aug 23 11:31:53 2012 -0400

    Be sure to clean up in the right order when unloading
    
    We should only free the userstate after all the pidgin stuff is cleaned
    up, as some of it may use the context.  Indeed, this fixes a crash bug
    when you try to unload the OTR module while a SMP session is in
    progress.
    
    The right thing to do is to deallocate things in the reverse order that
    you allocated them, which is what we do now.
---
 otr-plugin.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/otr-plugin.c b/otr-plugin.c
index 143f01d..1cee2a6 100644
--- a/otr-plugin.c
+++ b/otr-plugin.c
@@ -107,7 +107,7 @@ OtrlUserState otrg_plugin_userstate = NULL;
 
 /* GLib HashTable for storing the maximum message size for various
  * protocols. */
-GHashTable* mms_table;
+GHashTable* mms_table = NULL;
 
 
 /* Send an IM from the given account to the given recipient.  Display an
@@ -1160,6 +1160,7 @@ static void otrg_init_mms_table()
 static void otrg_free_mms_table()
 {
     g_hash_table_destroy(mms_table);
+    mms_table = NULL;
 }
 
 static gboolean otr_plugin_load(PurplePlugin *handle)
@@ -1301,10 +1302,11 @@ static gboolean otr_plugin_unload(PurplePlugin *handle)
     void *core_handle = purple_get_core();
 
     /* Clean up all of our state. */
-    otrl_userstate_free(otrg_plugin_userstate);
-    otrg_plugin_userstate = NULL;
 
-    otrg_free_mms_table();
+    purple_conversation_foreach(otrg_dialog_remove_conv);
+
+    otrg_dialog_cleanup();
+    otrg_ui_cleanup();
 
     purple_signal_disconnect(core_handle, "quitting", otrg_plugin_handle,
 	    PURPLE_CALLBACK(process_quitting));
@@ -1325,10 +1327,10 @@ static gboolean otr_plugin_unload(PurplePlugin *handle)
     purple_signal_disconnect(blist_handle, "blist-node-extended-menu",
 	    otrg_plugin_handle, PURPLE_CALLBACK(supply_extended_menu));
 
-    purple_conversation_foreach(otrg_dialog_remove_conv);
+    otrl_userstate_free(otrg_plugin_userstate);
+    otrg_plugin_userstate = NULL;
 
-    otrg_dialog_cleanup();
-    otrg_ui_cleanup();
+    otrg_free_mms_table();
 
     return 1;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-otr/packages/irssi-plugin-otr.git



More information about the Pkg-otr-team mailing list