Skip to content

Commit

Permalink
Check sticker pointer before use.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Nov 14, 2021
1 parent 5e70be9 commit ed56a75
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions td/telegram/StickersManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3173,6 +3173,7 @@ vector<FileId> 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(),
Expand All @@ -3183,6 +3184,7 @@ vector<FileId> 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);
Expand Down Expand Up @@ -3269,6 +3271,7 @@ vector<FileId> 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;
Expand Down

0 comments on commit ed56a75

Please sign in to comment.