diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index c9e66759b8..5852a9606a 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -54,6 +54,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { constexpr auto kDefaultCoverThumbnailSize = 100; +constexpr auto kMaxAllowedPreloadPrefix = 6 * 1024 * 1024; const auto kLottieStickerDimensions = QSize( kStickerSideSize, @@ -393,7 +394,7 @@ void DocumentData::setattributes( if (data.is_round_message()) { _additional = std::make_unique(); } else if (const auto size = data.vpreload_prefix_size()) { - if (size->v > 0) { + if (size->v > 0 && size->v < kMaxAllowedPreloadPrefix) { _videoPreloadPrefix = size->v; } } diff --git a/Telegram/SourceFiles/data/data_stories.h b/Telegram/SourceFiles/data/data_stories.h index c4d55a1293..48ea796886 100644 --- a/Telegram/SourceFiles/data/data_stories.h +++ b/Telegram/SourceFiles/data/data_stories.h @@ -217,7 +217,7 @@ public: void registerPolling(not_null story, Polling polling); void unregisterPolling(not_null story, Polling polling); - bool registerPolling(FullStoryId id, Polling polling); + [[nodiscard]] bool registerPolling(FullStoryId id, Polling polling); void unregisterPolling(FullStoryId id, Polling polling); void requestUserStories( not_null user, diff --git a/Telegram/SourceFiles/data/data_story.cpp b/Telegram/SourceFiles/data/data_story.cpp index 2a139de87b..fbc678581a 100644 --- a/Telegram/SourceFiles/data/data_story.cpp +++ b/Telegram/SourceFiles/data/data_story.cpp @@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "media/streaming/media_streaming_reader.h" #include "storage/download_manager_mtproto.h" +#include "storage/file_download.h" // kMaxFileInMemory #include "ui/text/text_utilities.h" namespace Data { @@ -574,6 +575,7 @@ void StoryPreload::load() { } _task = std::make_unique(id(), video, [=](QByteArray data) { if (!data.isEmpty()) { + Assert(data.size() < Storage::kMaxFileInMemory); _story->owner().cacheBigFile().putIfEmpty( key, Storage::Cache::Database::TaggedValue(std::move(data), 0)); diff --git a/Telegram/SourceFiles/data/stickers/data_custom_emoji.cpp b/Telegram/SourceFiles/data/stickers/data_custom_emoji.cpp index ffedf1f509..b9f34f0300 100644 --- a/Telegram/SourceFiles/data/stickers/data_custom_emoji.cpp +++ b/Telegram/SourceFiles/data/stickers/data_custom_emoji.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lottie/lottie_frame_generator.h" #include "ffmpeg/ffmpeg_frame_generator.h" #include "chat_helpers/stickers_lottie.h" +#include "storage/file_download.h" // kMaxFileInMemory #include "ui/widgets/input_fields.h" #include "ui/text/text_custom_emoji.h" #include "ui/text/text_utilities.h" @@ -345,7 +346,7 @@ void CustomEmojiLoader::check() { }; auto put = [=, key = cacheKey(document)](QByteArray value) { const auto size = value.size(); - if (size <= Storage::Cache::Database::Settings().maxDataSize) { + if (size <= Storage::kMaxFileInMemory) { document->owner().cacheBigFile().put(key, std::move(value)); } else { LOG(("Data Error: Cached emoji size too big: %1.").arg(size)); diff --git a/Telegram/SourceFiles/info/stories/info_stories_provider.cpp b/Telegram/SourceFiles/info/stories/info_stories_provider.cpp index e582f9ce7e..82f0ca5f28 100644 --- a/Telegram/SourceFiles/info/stories/info_stories_provider.cpp +++ b/Telegram/SourceFiles/info/stories/info_stories_provider.cpp @@ -283,9 +283,10 @@ BaseLayout *Provider::getLayout( if (auto layout = createLayout(id, delegate)) { layout->initDimensions(); it = _layouts.emplace(id, std::move(layout)).first; - _peer->owner().stories().registerPolling( + const auto ok = _peer->owner().stories().registerPolling( { _peer->id, id }, Data::Stories::Polling::Chat); + Assert(ok); } else { return nullptr; }