From 0be787f1e414d4a3be148422a963c81ef1d1c6d7 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 11 Feb 2018 06:39:06 -0600 Subject: [PATCH] RoomList: do not blindly dereference RoomState (#232) This can happen when a new room is being created from a different client and thus is created with no known state to the local client. --- src/RoomList.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/RoomList.cc b/src/RoomList.cc index 1f8747ae..d4b12690 100644 --- a/src/RoomList.cc +++ b/src/RoomList.cc @@ -198,13 +198,16 @@ RoomList::sync(const std::map> &states, if (!roomExists(state.first)) addRoom(settings.at(state.first), state.second, state.first); - auto room = rooms_[state.first]; + auto room = rooms_[state.first]; + auto room_state = room->state(); - auto current_avatar = room->state()->getAvatar(); - auto new_avatar = state.second->getAvatar(); + if (room_state) { + auto current_avatar = room_state->getAvatar(); + auto new_avatar = state.second->getAvatar(); - if (current_avatar != new_avatar && !new_avatar.toString().isEmpty()) - updateAvatar(state.first, new_avatar.toString()); + if (current_avatar != new_avatar && !new_avatar.toString().isEmpty()) + updateAvatar(state.first, new_avatar.toString()); + } room->setState(state.second); }