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:
Veres Károly authored and Tobias Fella committed 2026-01-10 14:48:09 +00:00
1 parent 3a416990ca
commit b684fb451d
1 file changed
+4 -1
+4 -1
View File
@@ -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());