Fix crash on invalid image data.

This commit is contained in:
John Preston
2020-05-30 22:37:03 +04:00
parent 4695ebae6e
commit 423ea5b499
6 changed files with 33 additions and 11 deletions
@@ -171,9 +171,14 @@ void DocumentMedia::setGoodThumbnail(QImage thumbnail) {
Image *DocumentMedia::thumbnailInline() const {
if (!_inlineThumbnail) {
auto image = Images::FromInlineBytes(_owner->inlineThumbnailBytes());
if (!image.isNull()) {
_inlineThumbnail = std::make_unique<Image>(std::move(image));
const auto bytes = _owner->inlineThumbnailBytes();
if (!bytes.isEmpty()) {
auto image = Images::FromInlineBytes(bytes);
if (image.isNull()) {
_owner->clearInlineThumbnailBytes();
} else {
_inlineThumbnail = std::make_unique<Image>(std::move(image));
}
}
}
return _inlineThumbnail.get();
@@ -360,10 +365,11 @@ Image *DocumentMedia::getStickerSmall() {
}
void DocumentMedia::checkStickerLarge(not_null<FileLoader*> loader) {
if (_owner->sticker()
&& !_sticker
&& !loader->imageData().isNull()) {
_sticker = std::make_unique<Image>(loader->imageData());
if (_sticker || !_owner->sticker()) {
return;
}
if (auto image = loader->imageData(); !image.isNull()) {
_sticker = std::make_unique<Image>(std::move(image));
}
}