diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index d92061220..d64a7d18e 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -1378,8 +1378,13 @@ vector UpdatesManager::get_update_ids(const telegram_api::Updates *update case telegram_api::updateShortChatMessage::ID: case telegram_api::updateShortSentMessage::ID: return {updates_type}; - case telegram_api::updateShort::ID: - return {static_cast(updates_ptr)->update_->get_id()}; + case telegram_api::updateShort::ID: { + const auto *update = static_cast(updates_ptr)->update_.get(); + if (update != nullptr) { + return {update->get_id()}; + } + return {updates_type}; + } case telegram_api::updatesCombined::ID: updates = &static_cast(updates_ptr)->updates_; break; @@ -1390,7 +1395,14 @@ vector UpdatesManager::get_update_ids(const telegram_api::Updates *update UNREACHABLE(); } - return transform(*updates, [](const tl_object_ptr &update) { return update->get_id(); }); + vector result; + result.reserve(updates->size()); + for (auto &update : *updates) { + if (update != nullptr) { + result.push_back(update->get_id()); + } + } + return result; } vector UpdatesManager::get_chat_dialog_ids(const telegram_api::Updates *updates_ptr) {