From a10b91fe1a208c01a04c8d531574d6ecd220c31e Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 1 Jul 2019 16:35:20 +0200 Subject: [PATCH] Don't load bad image infinitely. --- Telegram/SourceFiles/ui/image/image_source.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/ui/image/image_source.cpp b/Telegram/SourceFiles/ui/image/image_source.cpp index 1970e2af9..0c8d25dd2 100644 --- a/Telegram/SourceFiles/ui/image/image_source.cpp +++ b/Telegram/SourceFiles/ui/image/image_source.cpp @@ -275,12 +275,16 @@ QImage RemoteSource::takeLoaded() { return QImage(); } - auto data = _loader->imageData(shrinkBox()); - if (data.isNull()) { + if (_loader->cancelled()) { _cancelled = true; destroyLoader(); return QImage(); } + auto data = _loader->imageData(shrinkBox()); + if (data.isNull()) { + // Bad content in the image. + data = Image::Empty()->original(); + } setInformation(_loader->bytes().size(), data.width(), data.height()); @@ -303,7 +307,7 @@ void RemoteSource::destroyLoader() { void RemoteSource::loadLocal() { if (_loader) { - return; + return; } _loader = createLoader(Data::FileOrigin(), LoadFromLocalOnly, true);