From 58d334c1c8e0bde8073a833ccbf85cb2f8a8636b Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 6 Mar 2026 21:59:51 +0400 Subject: [PATCH] Fix crash in restrict-from-recent-actions. --- .../boxes/peers/edit_participant_box.cpp | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index 72d88cacfe..153bcf203b 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -942,20 +942,27 @@ void EditRestrictedBox::prepare() { if (!_saveCallback) { return; } + const auto show = uiShow(); + const auto rankPeer = peer(); + const auto rankUser = user(); + const auto rank = _tagControl + ? _tagControl->currentRank() + : _oldRank; + const auto saveRank = (rank != _oldRank); + + // May destroy the box. _saveCallback( _oldRights, ChatRestrictionsInfo{ value(), getRealUntilValue() }); - if (_tagControl) { - const auto rank = _tagControl->currentRank(); - if (rank != _oldRank) { - SaveMemberRank( - uiShow(), - peer(), - user(), - rank, - nullptr, - nullptr); - } + + if (saveRank) { + SaveMemberRank( + show, + rankPeer, + rankUser, + rank, + nullptr, + nullptr); } }; addButton(tr::lng_settings_save(), save);