diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index a85aa2ab6..bff06027f 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -1193,6 +1193,9 @@ static void parse(unique_ptr &content, ParserT &parser) { is_bad = true; } } + if (m->photo.is_empty()) { + is_bad = true; + } parse_caption(m->caption, parser); content = std::move(m); break; @@ -1776,7 +1779,8 @@ static Result create_input_message_content( if (file_view.has_remote_location() && !file_view.remote_location().is_web()) { message_photo->photo.id = file_view.remote_location().get_id(); - } else { + } + if (message_photo->photo.is_empty()) { message_photo->photo.id = 0; } message_photo->photo.date = G()->unix_time(); @@ -4933,9 +4937,13 @@ tl_object_ptr get_message_content_object(const MessageCo } case MessageContentType::Photo: { const auto *m = static_cast(content); - return make_tl_object( - get_photo_object(td->file_manager_.get(), m->photo), - get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp), is_content_secret); + auto photo = get_photo_object(td->file_manager_.get(), m->photo); + if (photo == nullptr) { + LOG(ERROR) << "Have empty " << m->photo; + return make_tl_object(); + } + auto caption = get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp); + return make_tl_object(std::move(photo), std::move(caption), is_content_secret); } case MessageContentType::Sticker: { const auto *m = static_cast(content);