From ed56a75b8aba26d16470e7001d5916443df9612f Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 14 Nov 2021 09:05:33 +0300 Subject: [PATCH] Check sticker pointer before use. --- td/telegram/StickersManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 3012bb53caa2..24c0ac32d52e 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -3173,6 +3173,7 @@ vector StickersManager::get_stickers(string emoji, int32 limit, bool for auto prefer_animated = [this](FileId lhs, FileId rhs) { const Sticker *lhs_s = get_sticker(lhs); const Sticker *rhs_s = get_sticker(rhs); + CHECK(lhs_s != nullptr && rhs_s != nullptr); return lhs_s->is_animated && !rhs_s->is_animated; }; // std::stable_sort(prepend_sticker_ids.begin(), prepend_sticker_ids.begin() + recent_sticker_ids_[0].size(), @@ -3183,6 +3184,7 @@ vector StickersManager::get_stickers(string emoji, int32 limit, bool for LOG(INFO) << "Have " << recent_sticker_ids_[0] << " recent and " << favorite_sticker_ids_ << " favorite stickers"; for (const auto &sticker_id : prepend_sticker_ids) { const Sticker *s = get_sticker(sticker_id); + CHECK(s != nullptr); LOG(INFO) << "Have prepend sticker " << sticker_id << " from " << s->set_id; if (s->set_id.is_valid() && !td::contains(sets_to_load, s->set_id)) { const StickerSet *sticker_set = get_sticker_set(s->set_id); @@ -3269,6 +3271,7 @@ vector StickersManager::get_stickers(string emoji, int32 limit, bool for is_good = true; } else { const Sticker *s = get_sticker(sticker_id); + CHECK(s != nullptr); if (remove_emoji_modifiers(s->alt) == emoji) { LOG(INFO) << "Found prepend sticker " << sticker_id << " main emoji matches"; is_good = true;