From 88a82eecf388823babd15132ed75e7fe1ade0e53 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 29 Oct 2018 17:32:34 +0400 Subject: [PATCH] Fix crash in unloaded null Image. --- Telegram/SourceFiles/ui/image/image_source.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/ui/image/image_source.cpp b/Telegram/SourceFiles/ui/image/image_source.cpp index 22dd4e7c5..f52d4e206 100644 --- a/Telegram/SourceFiles/ui/image/image_source.cpp +++ b/Telegram/SourceFiles/ui/image/image_source.cpp @@ -43,12 +43,14 @@ QImage ImageSource::takeLoaded() { void ImageSource::unload() { if (_bytes.isEmpty() && !_data.isNull()) { - if (_format.isEmpty()) { + if (_format != "JPG") { _format = "PNG"; } - - QBuffer buffer(&_bytes); - _data.save(&buffer, _format); + { + QBuffer buffer(&_bytes); + _data.save(&buffer, _format); + } + Assert(!_bytes.isEmpty()); } _data = QImage(); }