aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2022-04-09 02:00:52 +0200
committerTobias Fella <fella@posteo.de>2022-04-09 15:52:11 +0200
commitb0a43c3534865b9fcc1af90ee2c821ac11b2a204 (patch)
tree93353a864b85656d7c06cb92c53a51a7a25134f9 /lib
parent5c93193508a49b79a92fd0d80cf4db14f1d0762e (diff)
downloadlibquotient-b0a43c3534865b9fcc1af90ee2c821ac11b2a204.tar.gz
libquotient-b0a43c3534865b9fcc1af90ee2c821ac11b2a204.zip
Don't crash when decrypting existing messages
Diffstat (limited to 'lib')
-rw-r--r--lib/room.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 88aa1d07..3ba6890a 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -1512,7 +1512,8 @@ void Room::handleRoomKeyEvent(const RoomKeyEvent& roomKeyEvent,
roomKeyEvent.sessionKey(), roomKeyEvent.fullJson()["keys"]["ed25519"].toString())) {
qCWarning(E2EE) << "added new inboundGroupSession:"
<< d->groupSessions.size();
- for (const auto& eventId : d->undecryptedEvents[roomKeyEvent.sessionId()]) {
+ auto undecryptedEvents = d->undecryptedEvents[roomKeyEvent.sessionId()];
+ for (const auto& eventId : undecryptedEvents) {
const auto pIdx = d->eventsIndex.constFind(eventId);
if (pIdx == d->eventsIndex.cend())
continue;
@@ -1524,7 +1525,7 @@ void Room::handleRoomKeyEvent(const RoomKeyEvent& roomKeyEvent,
auto& decryptedEvent = *decrypted;
auto oldEvent = ti.replaceEvent(std::move(decrypted));
decryptedEvent.setOriginalEvent(std::move(oldEvent));
- emit replacedEvent(ti.event(), decrypted->originalEvent());
+ emit replacedEvent(ti.event(), decryptedEvent.originalEvent());
d->undecryptedEvents[roomKeyEvent.sessionId()] -= eventId;
}
}