summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-07-17 12:51:38 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-07-17 12:51:38 +0300
commit663e942457c17e004a72d33c844c5185c5d3f1ae (patch)
tree3fffa83c82c579e752588677793b596a01d8247f
parent36bae0cb914a64f5c9ce9a8e2b606b53cef7fd88 (diff)
Telegram: fix for rare crash
-rw-r--r--protocols/Telegram/src/utils.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp
index a317ff2d21..407a28ca8c 100644
--- a/protocols/Telegram/src/utils.cpp
+++ b/protocols/Telegram/src/utils.cpp
@@ -425,29 +425,33 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg
break;
case TD::messageAnimatedEmoji::ID:
- if (m_bSmileyAdd) {
- 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;
+ {
+ auto *pObj = (TD::messageAnimatedEmoji *)pBody;
+ if (m_bSmileyAdd) {
+ if (auto *pAnimated = pObj->animated_emoji_.get()) {
+ if (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);
+ }
}
-
- return GetMessageSticker(pSticker->thumbnail_->file_.get(), pwszFileExt);
}
+ return pObj->emoji_.c_str();
}
- break;
case TD::messageSticker::ID:
{