From 1cace9e666612e1bf53f6c6eaabeef1d76232c56 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 5 Jun 2022 22:51:13 +0300 Subject: [PATCH] Ensure that message chat photo is not null. --- td/telegram/MessageContent.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index bff06027f..d64234a7b 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -1271,6 +1271,9 @@ static void parse(unique_ptr &content, ParserT &parser) { case MessageContentType::ChatChangePhoto: { auto m = make_unique(); parse(m->photo, parser); + if (m->photo.is_empty()) { + is_bad = true; + } content = std::move(m); break; } @@ -4995,7 +4998,12 @@ tl_object_ptr get_message_content_object(const MessageCo } case MessageContentType::ChatChangePhoto: { const auto *m = static_cast(content); - return make_tl_object(get_chat_photo_object(td->file_manager_.get(), m->photo)); + auto photo = get_chat_photo_object(td->file_manager_.get(), m->photo); + if (photo == nullptr) { + LOG(ERROR) << "Have empty chat " << m->photo; + return make_tl_object(); + } + return make_tl_object(std::move(photo)); } case MessageContentType::ChatDeletePhoto: return make_tl_object();