summary refs log tree commit diff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-07-01 09:14:17 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-07-01 09:14:17 +0200
commit7198cee85e19f020e8e517b4d7f0f60f2bff88f8 (patch)
treeb01c87dfe6f8eb94926227cd4a991e9f04a1b139 /src/Cache.cpp
parentFix crash when closing room directory window (diff)
downloadnheko-7198cee85e19f020e8e517b4d7f0f60f2bff88f8.tar.xz
Fix crash on empty user cache stored
Diffstat (limited to '')
-rw-r--r--src/Cache.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp

index 67889543..c9baaf5e 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp
@@ -4442,11 +4442,15 @@ Cache::markUserKeysOutOfDate(lmdb::txn &txn, std::string_view oldKeys; - UserKeyCache cacheEntry; + UserKeyCache cacheEntry{}; auto res = db.get(txn, user, oldKeys); if (res) { - cacheEntry = nlohmann::json::parse(std::string_view(oldKeys.data(), oldKeys.size())) - .get<UserKeyCache>(); + try { + cacheEntry = nlohmann::json::parse(std::string_view(oldKeys.data(), oldKeys.size())) + .get<UserKeyCache>(); + } catch (std::exception &e) { + nhlog::db()->error("Failed to parse {}: {}", oldKeys, e.what()); + } } cacheEntry.last_changed = sync_token;