From 5e45a7d963b848ff9603575948f03927e5ed0b3a Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 30 Oct 2015 11:41:13 +0000 Subject: 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. --- matrix-sync.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'matrix-sync.c') diff --git a/matrix-sync.c b/matrix-sync.c index 2f3b887..9190656 100644 --- a/matrix-sync.c +++ b/matrix-sync.c @@ -177,6 +177,8 @@ void matrix_sync_parse(PurpleConnection *pc, JsonNode *body, rooms = matrix_json_object_get_object_member(rootObj, "rooms"); joined_rooms = matrix_json_object_get_object_member(rooms, "joined"); + *next_batch = matrix_json_object_get_string_member(rootObj, "next_batch"); + if(joined_rooms == NULL) { purple_debug_warning("matrixprpl", "didn't find joined rooms list\n"); return; @@ -187,10 +189,9 @@ void matrix_sync_parse(PurpleConnection *pc, JsonNode *body, const gchar *room_id = elem->data; JsonObject *room_data = matrix_json_object_get_object_member( joined_rooms, room_id); + purple_debug_info("matrixprpl", "Syncing room %s", room_id); matrix_sync_room(room_id, room_data, pc); } g_list_free(room_ids); - - *next_batch = matrix_json_object_get_string_member(rootObj, "next_batch"); } -- cgit