From 0e26b39faf2d5375f20d86459b60cd9c0cbd0578 Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Wed, 13 Mar 2024 16:34:39 +0300 Subject: [PATCH] fix: possible crash --- Telegram/SourceFiles/ayu/data/ayu_database.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/ayu/data/ayu_database.cpp b/Telegram/SourceFiles/ayu/data/ayu_database.cpp index 9657f1dd5..562fbffb2 100644 --- a/Telegram/SourceFiles/ayu/data/ayu_database.cpp +++ b/Telegram/SourceFiles/ayu/data/ayu_database.cpp @@ -153,13 +153,19 @@ void moveCurrentDatabase() { } void initialize() { - const auto res = storage.sync_schema_simulate(true); auto movePrevious = false; - for (const auto val : res | std::views::values) { - if (val == sync_schema_result::dropped_and_recreated) { - movePrevious = true; - break; + + try { + const auto res = storage.sync_schema_simulate(true); + for (const auto val : res | std::views::values) { + if (val == sync_schema_result::dropped_and_recreated) { + movePrevious = true; + break; + } } + } catch (...) { + LOG(("Exception during sync simulation; possibly corrupted database")); + movePrevious = true; } if (movePrevious) {