From 5de83ef30ca4ec203e01f67ff9ed40944d450118 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 27 Aug 2021 18:21:46 +0300 Subject: [PATCH] Fix assertion violation in profile video with zero file size. --- Telegram/SourceFiles/data/data_session.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 1068f1cb3d..0c28808fa7 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -2619,13 +2619,14 @@ void Session::photoApplyFields( } const auto area = [](const MTPVideoSize &size) { return size.match([](const MTPDvideoSize &data) { - return data.vw().v * data.vh().v; + return data.vsize().v ? (data.vw().v * data.vh().v) : 0; }); }; - return *ranges::max_element( + const auto result = *ranges::max_element( sizes->v, std::greater<>(), area); + return (area(result) > 0) ? std::make_optional(result) : std::nullopt; }; const auto useProgressive = (progressive != sizes.end()); const auto large = useProgressive