# HG changeset patch # User Elliott Sales de Andrade # Date 1248148604 0 # Node ID f24885ec506b488db79b2177bbd73bf640720d0d # Parent 577bf7ea039511ae0e9606b77ecba3a16736ac01 Set the session error after disconnecting the servconn instead of before. The disconnect callback may try to do something that would set another error, thus hiding the original one. diff -r 577bf7ea0395 -r f24885ec506b libpurple/protocols/msn/servconn.c --- a/libpurple/protocols/msn/servconn.c Mon Jul 20 05:11:50 2009 +0000 +++ b/libpurple/protocols/msn/servconn.c Tue Jul 21 03:56:44 2009 +0000 @@ -125,13 +125,14 @@ void msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error) { - char *tmp; + MsnSession *session = servconn->session; + MsnServConnType type = servconn->type; const char *reason; const char *names[] = { "Notification", "Switchboard" }; const char *name; - name = names[servconn->type]; + name = names[type]; switch (error) { @@ -147,14 +148,8 @@ purple_debug_error("msn", "Connection error from %s server (%s): %s\n", name, servconn->host, reason); - tmp = g_strdup_printf(_("Connection error from %s server:\n%s"), - name, reason); - if (servconn->type == MSN_SERVCONN_NS) - { - msn_session_set_error(servconn->session, MSN_ERROR_SERVCONN, tmp); - } - else if (servconn->type == MSN_SERVCONN_SB) + if (type == MSN_SERVCONN_SB) { MsnSwitchBoard *swboard; swboard = servconn->cmdproc->data; @@ -162,9 +157,16 @@ swboard->error = MSN_SB_ERROR_CONNECTION; } + /* servconn->disconnect_cb may destroy servconn, so don't use it again */ msn_servconn_disconnect(servconn); - g_free(tmp); + if (type == MSN_SERVCONN_NS) + { + char *tmp = g_strdup_printf(_("Connection error from %s server:\n%s"), + name, reason); + msn_session_set_error(session, MSN_ERROR_SERVCONN, tmp); + g_free(tmp); + } } /**************************************************************************