From 0f98d766837c9ec2875470d2f71a8acdea5eb2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liru=20F=C3=A6rs?= Date: Sun, 14 Jan 2024 17:02:56 -0500 Subject: [PATCH] Fix DialogActionManager::send_dialog_action in secret chats (#2756) * Fix DialogActionManager::send_dialog_action in secret chats The code in `DialogActionManager::send_dialog_action` made the assumption that since we'd either have early returned or `DialogManager::have_input_peer` would be true, and therefore the else block of the conditional, which intended to set input_peer, should have done so successfully. However, `DialogManager::have_input_peer` will return true for secret chats when `contacts_manager->have_input_encrypted_peer` And `DialogManager::get_input_peer` will return a `nullptr` for secret chats by design (I believe this is because they operate using structures that are currently incompatible) This should fix the root of a crash that happens when typing in or sending messages to secret chats on: Telegram X 0.26.4.1678-arm64-v8a (99b10675) TDLib: 1.8.23 (tdlib/td@4bafdc2) * Move CHECK below SecretChat case instead per feedback --- td/telegram/DialogActionManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/td/telegram/DialogActionManager.cpp b/td/telegram/DialogActionManager.cpp index 1754eacfb..fa07adc94 100644 --- a/td/telegram/DialogActionManager.cpp +++ b/td/telegram/DialogActionManager.cpp @@ -318,7 +318,6 @@ void DialogActionManager::send_dialog_action(DialogId dialog_id, MessageId top_t } input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write); - CHECK(input_peer != nullptr); } if (dialog_id.get_type() == DialogType::SecretChat) { @@ -328,6 +327,8 @@ void DialogActionManager::send_dialog_action(DialogId dialog_id, MessageId top_t return; } + CHECK(input_peer != nullptr); + auto new_query_ref = td_->create_handler(std::move(promise)) ->send(dialog_id, std::move(input_peer), top_thread_message_id, action.get_input_send_message_action());