From a9a8a147e232c322f7d5128a480a1d96ed234370 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Mon, 25 Nov 2013 14:26:42 +0200 Subject: [PATCH] Fix #222: SIPE crashes when groupchat session expires (I) The debug log shows that for some unknown reason the groupchat session has expired and the server responds with 481. This response causes SIPE to automatically close the dialog. The next time we send try to send a message to the groupchat session we get NULL for a dialog. We didn't check for this condition and therefore the code crashes. As a quick fix we now check dialog == NULL and don't send the message. (cherry picked from commit eeb27a3e53c4591f417b6d8ce3cbb738a36a4de5) --- src/core/sipe-groupchat.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/core/sipe-groupchat.c b/src/core/sipe-groupchat.c index 17cea094..72eb56b6 100644 --- a/src/core/sipe-groupchat.c +++ b/src/core/sipe-groupchat.c @@ -370,7 +370,8 @@ static void groupchat_update_cb(struct sipe_core_private *sipe_private, struct sip_dialog *dialog = sipe_dialog_find(groupchat->session, groupchat->session->with); - sip_transport_update(sipe_private, dialog); + if (dialog) + sip_transport_update(sipe_private, dialog); sipe_schedule_seconds(sipe_private, "<+groupchat-expires>", NULL, @@ -494,21 +495,25 @@ static struct sipe_groupchat_msg *chatserver_command(struct sipe_core_private *s const gchar *cmd) { struct sipe_groupchat *groupchat = sipe_private->groupchat; - struct sipe_groupchat_msg *msg = generate_xccos_message(groupchat, cmd); - struct sip_dialog *dialog = sipe_dialog_find(groupchat->session, groupchat->session->with); - - struct transaction_payload *payload = g_new0(struct transaction_payload, 1); - struct transaction *trans = sip_transport_info(sipe_private, - "Content-Type: text/plain\r\n", - msg->xccos, - dialog, - chatserver_command_response); - - payload->destroy = sipe_groupchat_msg_remove; - payload->data = msg; - trans->payload = payload; + struct sipe_groupchat_msg *msg = NULL; + + if (dialog) { + struct transaction_payload *payload = g_new0(struct transaction_payload, 1); + struct transaction *trans; + + msg = generate_xccos_message(groupchat, cmd); + trans = sip_transport_info(sipe_private, + "Content-Type: text/plain\r\n", + msg->xccos, + dialog, + chatserver_command_response); + + payload->destroy = sipe_groupchat_msg_remove; + payload->data = msg; + trans->payload = payload; + } return(msg); } @@ -1094,8 +1099,10 @@ void sipe_groupchat_send(struct sipe_core_private *sipe_private, msg = chatserver_command(sipe_private, cmd); g_free(cmd); - msg->session = chat_session; - msg->content = g_strdup(what); + if (msg) { + msg->session = chat_session; + msg->content = g_strdup(what); + } } void sipe_groupchat_leave(struct sipe_core_private *sipe_private, -- 2.11.4.GIT