From 907696b103b6e25721dfb543e5f85c43f69929f9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 29 Jun 2023 16:57:20 +0300 Subject: Telegram: fix for occasional crash --- protocols/Telegram/src/utils.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'protocols') diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index d646e96123..a317ff2d21 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -426,24 +426,26 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg case TD::messageAnimatedEmoji::ID: if (m_bSmileyAdd) { - auto *pSticker = ((TD::messageAnimatedEmoji *)pBody)->animated_emoji_->sticker_.get(); - if (!checkStickerType(pSticker->full_type_->get_id())) { - debugLogA("You received a sticker of unsupported type %d, ignored", pSticker->full_type_->get_id()); - break; + if (auto *pAnimated = ((TD::messageAnimatedEmoji *)pBody)->animated_emoji_.get()) { + auto *pSticker = pAnimated->sticker_.get(); + if (!checkStickerType(pSticker->full_type_->get_id())) { + debugLogA("You received a sticker of unsupported type %d, ignored", pSticker->full_type_->get_id()); + break; + } + + const char *pwszFileExt; + switch (pSticker->thumbnail_->format_->get_id()) { + case TD::thumbnailFormatGif::ID: pwszFileExt = "gif"; break; + case TD::thumbnailFormatPng::ID: pwszFileExt = "png"; break; + case TD::thumbnailFormatTgs::ID: pwszFileExt = "tga"; break; + case TD::thumbnailFormatJpeg::ID: pwszFileExt = "jpg"; break; + case TD::thumbnailFormatWebm::ID: pwszFileExt = "webm"; break; + case TD::thumbnailFormatWebp::ID: pwszFileExt = "webp"; break; + default:pwszFileExt = "jpeg"; break; + } + + return GetMessageSticker(pSticker->thumbnail_->file_.get(), pwszFileExt); } - - const char *pwszFileExt; - switch (pSticker->thumbnail_->format_->get_id()) { - case TD::thumbnailFormatGif::ID: pwszFileExt = "gif"; break; - case TD::thumbnailFormatPng::ID: pwszFileExt = "png"; break; - case TD::thumbnailFormatTgs::ID: pwszFileExt = "tga"; break; - case TD::thumbnailFormatJpeg::ID: pwszFileExt = "jpg"; break; - case TD::thumbnailFormatWebm::ID: pwszFileExt = "webm"; break; - case TD::thumbnailFormatWebp::ID: pwszFileExt = "webp"; break; - default:pwszFileExt = "jpeg"; break; - } - - return GetMessageSticker(pSticker->thumbnail_->file_.get(), pwszFileExt); } break; -- cgit v1.2.3