From 4695ebae6e59d0d395aeadfb0d5c3e58db53d222 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 30 May 2020 22:24:35 +0400 Subject: [PATCH] Fix crash in sticker set parsing. --- Telegram/SourceFiles/chat_helpers/stickers.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/stickers.cpp b/Telegram/SourceFiles/chat_helpers/stickers.cpp index ae535cd1ed..61d2288560 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers.cpp @@ -973,16 +973,19 @@ Set *FeedSetFull(const MTPmessages_StickerSet &data) { const auto &s = d.vset().c_stickerSet(); auto &sets = Auth().data().stickerSetsRef(); - auto it = sets.find(s.vid().v); - const auto wasArchived = (it->second->flags & MTPDstickerSet::Flag::f_archived); + const auto wasArchived = [&] { + auto it = sets.find(s.vid().v); + return (it != sets.end()) + && (it->second->flags & MTPDstickerSet::Flag::f_archived); + }(); auto set = FeedSet(s); set->flags &= ~MTPDstickerSet_ClientFlag::f_not_loaded; - auto &d_docs = d.vdocuments().v; + const auto &d_docs = d.vdocuments().v; auto customIt = sets.find(Stickers::CustomSetId); - auto inputSet = MTP_inputStickerSetID( + const auto inputSet = MTP_inputStickerSetID( MTP_long(set->id), MTP_long(set->access)); @@ -1055,7 +1058,7 @@ Set *FeedSetFull(const MTPmessages_StickerSet &data) { } if (set) { - const auto isArchived = (set->flags & MTPDstickerSet::Flag::f_archived); + const auto isArchived = !!(set->flags & MTPDstickerSet::Flag::f_archived); if (set->flags & MTPDstickerSet::Flag::f_installed_date) { if (!isArchived) { Local::writeInstalledStickers();