Possibly fix crash on accepting invites

fixes #857
This commit is contained in:
Nicolas Werner 2022-01-03 03:57:57 +01:00
parent eee61cd524
commit f14f978c48
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
1 changed files with 31 additions and 27 deletions

View File

@ -2789,6 +2789,9 @@ std::vector<RoomMember>
Cache::getMembersFromInvite(const std::string &room_id, std::size_t startIndex, std::size_t len)
{
auto txn = ro_txn(env_);
std::vector<RoomMember> members;
try {
auto db = getInviteMembersDb(txn, room_id);
auto cursor = lmdb::cursor::open(txn, db);
@ -2796,8 +2799,6 @@ Cache::getMembersFromInvite(const std::string &room_id, std::size_t startIndex,
const auto endIndex = std::min(startIndex + len, db.size(txn));
std::vector<RoomMember> members;
std::string_view user_id, user_data;
while (cursor.get(user_id, user_data, MDB_NEXT)) {
if (currentIndex < startIndex) {
@ -2821,6 +2822,9 @@ Cache::getMembersFromInvite(const std::string &room_id, std::size_t startIndex,
}
cursor.close();
} catch (const lmdb::error &e) {
nhlog::db()->warn("Failed to retrieve members {}", e.what());
}
return members;
}