From c480ab1a3b1c050e103195b907a2125f2da87a38 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 28 Oct 2023 21:13:52 +0400 Subject: [PATCH] Fix possible crash in non-cancelled request. --- Telegram/SourceFiles/data/data_group_call.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/data/data_group_call.cpp b/Telegram/SourceFiles/data/data_group_call.cpp index 613920d99..0567477c4 100644 --- a/Telegram/SourceFiles/data/data_group_call.cpp +++ b/Telegram/SourceFiles/data/data_group_call.cpp @@ -123,6 +123,7 @@ void GroupCall::requestParticipants() { return; } } + api().request(base::take(_participantsRequestId)).cancel(); _participantsRequestId = api().request(MTPphone_GetGroupParticipants( input(), MTP_vector(), // ids @@ -132,8 +133,8 @@ void GroupCall::requestParticipants() { : _nextOffset), MTP_int(kRequestPerPage) )).done([=](const MTPphone_GroupParticipants &result) { + _participantsRequestId = 0; result.match([&](const MTPDphone_groupParticipants &data) { - _participantsRequestId = 0; const auto reloaded = processSavedFullCall(); _nextOffset = qs(data.vnext_offset()); _peer->owner().processUsers(data.vusers()); @@ -168,7 +169,7 @@ bool GroupCall::processSavedFullCall() { if (!_savedFull) { return false; } - _reloadRequestId = 0; + api().request(base::take(_reloadRequestId)).cancel(); _reloadLastFinished = crl::now(); processFullCallFields(*base::take(_savedFull)); return true; @@ -511,10 +512,8 @@ void GroupCall::reloadIfStale() { void GroupCall::reload() { if (_reloadRequestId || _applyingQueuedUpdates) { return; - } else if (_participantsRequestId) { - api().request(_participantsRequestId).cancel(); - _participantsRequestId = 0; } + api().request(base::take(_participantsRequestId)).cancel(); DEBUG_LOG(("Group Call Participants: " "Reloading with queued: %1"