Null check pinned messages after decryption when filling PinnedMessageModel.
`room()->decryptMessage()` returns null if the message fails to decode. Since elements of `m_pinnedEvents` get directly dereferenced in getEventForIndex, storing null values leads to a segfault. In this case we should retain the EncryptedEvent to let the UI report the error.
This commit is contained in:
committed by
Tobias Fella
parent
3a416990ca
commit
b684fb451d
@@ -57,7 +57,10 @@ void PinnedMessageModel::fill()
|
||||
beginInsertRows({}, m_pinnedEvents.size(), m_pinnedEvents.size());
|
||||
auto ev = fromJson<event_ptr_tt<RoomEvent>>(job->jsonData());
|
||||
if (auto encEv = eventCast<EncryptedEvent>(ev.get())) {
|
||||
ev = room()->decryptMessage(*encEv);
|
||||
auto decryptedEvent = room()->decryptMessage(*encEv);
|
||||
if (decryptedEvent) {
|
||||
ev = std::move(decryptedEvent);
|
||||
}
|
||||
}
|
||||
m_pinnedEvents.push_back(std::move(ev));
|
||||
Q_EMIT newEventAdded(m_pinnedEvents.back().get());
|
||||
|
||||
Reference in New Issue
Block a user