Ensure that list size limit isn't exceeded.

GitOrigin-RevId: eded5582f4828928ca37fe64cde6c58fb469242c
This commit is contained in:
levlam 2018-03-08 17:17:53 +03:00
parent 6669bd8c7b
commit 34f6fd8942
2 changed files with 9 additions and 0 deletions

View File

@ -447,6 +447,9 @@ void AnimationsManager::on_load_saved_animations_from_database(const string &val
}
void AnimationsManager::on_load_saved_animations_finished(vector<FileId> &&saved_animation_ids, bool from_database) {
if (static_cast<int32>(saved_animation_ids.size()) > saved_animations_limit_) {
saved_animation_ids.resize(saved_animations_limit_);
}
saved_animation_ids_ = std::move(saved_animation_ids);
are_saved_animations_loaded_ = true;
send_update_saved_animations(from_database);

View File

@ -3396,6 +3396,9 @@ void StickersManager::on_load_recent_stickers_from_database(bool is_attached, st
void StickersManager::on_load_recent_stickers_finished(bool is_attached, vector<FileId> &&recent_sticker_ids,
bool from_database) {
if (static_cast<int32>(recent_sticker_ids.size()) > recent_stickers_limit_) {
recent_sticker_ids.resize(recent_stickers_limit_);
}
recent_sticker_ids_[is_attached] = std::move(recent_sticker_ids);
are_recent_stickers_loaded_[is_attached] = true;
need_update_recent_stickers_[is_attached] = true;
@ -3740,6 +3743,9 @@ void StickersManager::on_load_favorite_stickers_from_database(const string &valu
}
void StickersManager::on_load_favorite_stickers_finished(vector<FileId> &&favorite_sticker_ids, bool from_database) {
if (static_cast<int32>(favorite_sticker_ids.size()) > favorite_stickers_limit_) {
favorite_sticker_ids.resize(favorite_stickers_limit_);
}
favorite_sticker_ids_ = std::move(favorite_sticker_ids);
are_favorite_stickers_loaded_ = true;
send_update_favorite_stickers(from_database);