diff options
author | Richard van der Hoff <richard@matrix.org> | 2015-10-30 11:41:13 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2015-10-30 11:41:13 +0000 |
commit | 5e45a7d963b848ff9603575948f03927e5ed0b3a (patch) | |
tree | 90799f23c5eca38e05f82c1d981484f935817ac9 /matrix-connection.c | |
parent | ed0c5f6b5ad82df7047296adb081e19102ec4a35 (diff) | |
download | purple-matrix-5e45a7d963b848ff9603575948f03927e5ed0b3a.tar.gz |
Fix segfault on homeserver connection drop
If the connection dropped in the middle of us receiving a sync response, we
tried to set the next_batch setting on the account to an invalid string
(because we failed to initialise the pointer). Fix the segfault that caused,
and clean up some of the other error handling in the area at the same time.
Diffstat (limited to 'matrix-connection.c')
-rw-r--r-- | matrix-connection.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/matrix-connection.c b/matrix-connection.c index 925fef6..b77942a 100644 --- a/matrix-connection.c +++ b/matrix-connection.c @@ -109,6 +109,14 @@ static void _sync_complete(MatrixConnectionData *ma, gpointer user_data, PurpleConnection *pc = ma->pc; const gchar *next_batch; + ma->active_sync = NULL; + + if(body == NULL) { + purple_connection_error_reason(pc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, + "Couldn't parse sync response"); + return; + } + purple_connection_update_progress(pc, _("Connected"), 2, 3); purple_connection_set_state(pc, PURPLE_CONNECTED); @@ -116,8 +124,8 @@ static void _sync_complete(MatrixConnectionData *ma, gpointer user_data, /* Start the next sync */ if(next_batch == NULL) { - purple_connection_error_reason(pc, - PURPLE_CONNECTION_ERROR_OTHER_ERROR, "No next_batch field"); + purple_connection_error_reason(pc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, + "No next_batch field"); return; } purple_account_set_string(pc->account, PRPL_ACCOUNT_OPT_NEXT_BATCH, |