Fix crash for invalid inline bot stickers.

This commit is contained in:
John Preston 2018-06-28 15:15:47 +01:00
parent d8897a0cc8
commit 2f5fb3688a
2 changed files with 26 additions and 11 deletions

View File

@ -362,7 +362,8 @@ void Gif::clipCallback(Media::Clip::Notification notification) {
}
}
Sticker::Sticker(not_null<Context*> context, Result *result) : FileBase(context, result) {
Sticker::Sticker(not_null<Context*> context, Result *result)
: FileBase(context, result) {
}
void Sticker::initDimensions() {
@ -447,7 +448,9 @@ void Sticker::prepareThumb() const {
const auto sticker = goodThumb
? document->thumb
: document->sticker()->img;
: document->sticker()
? document->sticker()->img
: ImagePtr();
if (!_thumbLoaded && !sticker->isNull() && sticker->loaded()) {
QSize thumbSize = getThumbSize();
_thumb = sticker->pix(thumbSize.width(), thumbSize.height());
@ -467,7 +470,8 @@ void Sticker::prepareThumb() const {
}
}
Photo::Photo(not_null<Context*> context, Result *result) : ItemBase(context, result) {
Photo::Photo(not_null<Context*> context, Result *result)
: ItemBase(context, result) {
}
void Photo::initDimensions() {

View File

@ -99,17 +99,28 @@ std::unique_ptr<ItemBase> ItemBase::createLayout(not_null<Context*> context, Res
using Type = Result::Type;
switch (result->_type) {
case Type::Photo: return std::make_unique<internal::Photo>(context, result); break;
case Type::Photo:
return std::make_unique<internal::Photo>(context, result);
case Type::Audio:
case Type::File: return std::make_unique<internal::File>(context, result); break;
case Type::Video: return std::make_unique<internal::Video>(context, result); break;
case Type::Sticker: return std::make_unique<internal::Sticker>(context, result); break;
case Type::Gif: return std::make_unique<internal::Gif>(context, result); break;
case Type::File:
return std::make_unique<internal::File>(context, result);
case Type::Video:
return std::make_unique<internal::Video>(context, result);
case Type::Sticker:
return std::make_unique<internal::Sticker>(context, result);
case Type::Gif:
return std::make_unique<internal::Gif>(context, result);
case Type::Article:
case Type::Geo:
case Type::Venue: return std::make_unique<internal::Article>(context, result, forceThumb); break;
case Type::Game: return std::make_unique<internal::Game>(context, result); break;
case Type::Contact: return std::make_unique<internal::Contact>(context, result); break;
case Type::Venue:
return std::make_unique<internal::Article>(
context,
result,
forceThumb);
case Type::Game:
return std::make_unique<internal::Game>(context, result);
case Type::Contact:
return std::make_unique<internal::Contact>(context, result);
}
return nullptr;
}