From f129b6b90d1fc4afe61a6244266fd690375699d7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 22 Jun 2020 13:07:01 +0400 Subject: [PATCH] Fix invalid cache settings being read. --- Telegram/SourceFiles/storage/storage_account.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/storage/storage_account.cpp b/Telegram/SourceFiles/storage/storage_account.cpp index e6cc27782..1c278befd 100644 --- a/Telegram/SourceFiles/storage/storage_account.cpp +++ b/Telegram/SourceFiles/storage/storage_account.cpp @@ -820,10 +820,16 @@ std::unique_ptr Account::applyReadContext( ReadSettingsContext &&context) { ApplyReadFallbackConfig(context); - _cacheTotalSizeLimit = context.cacheTotalSizeLimit; - _cacheTotalTimeLimit = context.cacheTotalTimeLimit; - _cacheBigFileTotalSizeLimit = context.cacheBigFileTotalSizeLimit; - _cacheBigFileTotalTimeLimit = context.cacheBigFileTotalTimeLimit; + if (context.cacheTotalSizeLimit) { + _cacheTotalSizeLimit = context.cacheTotalSizeLimit; + _cacheTotalTimeLimit = context.cacheTotalTimeLimit; + _cacheBigFileTotalSizeLimit = context.cacheBigFileTotalSizeLimit; + _cacheBigFileTotalTimeLimit = context.cacheBigFileTotalTimeLimit; + + const auto &normal = Database::Settings(); + Assert(_cacheTotalSizeLimit > normal.maxDataSize); + Assert(_cacheBigFileTotalSizeLimit > normal.maxDataSize); + } if (!context.mtpAuthorization.isEmpty()) { _owner->setMtpAuthorization(context.mtpAuthorization);