Add some emptiness checks.

This commit is contained in:
levlam 2023-01-02 20:12:15 +03:00
parent 29c264df59
commit 5711c6c8eb
4 changed files with 6 additions and 0 deletions

View File

@ -12022,6 +12022,7 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
}
ContactsManager::UserPhotos *ContactsManager::add_user_photos(UserId user_id) {
CHECK(user_id.is_valid());
auto &user_photos_ptr = user_photos_[user_id];
if (user_photos_ptr == nullptr) {
user_photos_ptr = make_unique<UserPhotos>();

View File

@ -1837,6 +1837,7 @@ void UpdatesManager::try_reload_data() {
}
void UpdatesManager::subscribe_to_transcribed_audio_updates(int64 transcription_id, TranscribedAudioHandler on_update) {
CHECK(transcription_id != 0);
if (pending_audio_transcriptions_.count(transcription_id) != 0) {
on_pending_audio_transcription_failed(transcription_id,
Status::Error(500, "Receive duplicate speech recognition identifier"));

View File

@ -177,6 +177,7 @@ void VideoNotesManager::register_video_note(FileId video_note_file_id, FullMessa
return;
}
LOG(INFO) << "Register video note " << video_note_file_id << " from " << full_message_id << " from " << source;
CHECK(video_note_file_id.is_valid());
bool is_inserted = video_note_messages_[video_note_file_id].insert(full_message_id).second;
LOG_CHECK(is_inserted) << source << ' ' << video_note_file_id << ' ' << full_message_id;
is_inserted = message_video_notes_.emplace(full_message_id, video_note_file_id).second;
@ -190,6 +191,7 @@ void VideoNotesManager::unregister_video_note(FileId video_note_file_id, FullMes
return;
}
LOG(INFO) << "Unregister video note " << video_note_file_id << " from " << full_message_id << " from " << source;
CHECK(video_note_file_id.is_valid());
auto &message_ids = video_note_messages_[video_note_file_id];
auto is_deleted = message_ids.erase(full_message_id) > 0;
LOG_CHECK(is_deleted) << source << ' ' << video_note_file_id << ' ' << full_message_id;

View File

@ -141,6 +141,7 @@ void VoiceNotesManager::register_voice_note(FileId voice_note_file_id, FullMessa
return;
}
LOG(INFO) << "Register voice note " << voice_note_file_id << " from " << full_message_id << " from " << source;
CHECK(voice_note_file_id.is_valid());
bool is_inserted = voice_note_messages_[voice_note_file_id].insert(full_message_id).second;
LOG_CHECK(is_inserted) << source << ' ' << voice_note_file_id << ' ' << full_message_id;
is_inserted = message_voice_notes_.emplace(full_message_id, voice_note_file_id).second;
@ -154,6 +155,7 @@ void VoiceNotesManager::unregister_voice_note(FileId voice_note_file_id, FullMes
return;
}
LOG(INFO) << "Unregister voice note " << voice_note_file_id << " from " << full_message_id << " from " << source;
CHECK(voice_note_file_id.is_valid());
auto &message_ids = voice_note_messages_[voice_note_file_id];
auto is_deleted = message_ids.erase(full_message_id) > 0;
LOG_CHECK(is_deleted) << source << ' ' << voice_note_file_id << ' ' << full_message_id;