summaryrefslogtreecommitdiff
blob: 5a8e6ceedd66c921baec72e3c98872a4a6124c66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Description: Do not capture buttons in AccountsList that belong to inner VerticalLayout widget
 This fixes a use-after-free error (double destruction) in the main menu right after account switching.
Bug-Debian: https://bugs.debian.org/1008156
Bug-Ubuntu: https://launchpad.net/bugs/1967673
Forwarded: https://github.com/telegramdesktop/tdesktop/pull/24301
Author: Nicholas Guriev <guriev-ns@ya.ru>
Last-Update: Sat, 09 Apr 2022 13:47:55 +0300

--- tdesktop-3.6.1-full.orig/Telegram/SourceFiles/settings/settings_information.cpp
+++ tdesktop-3.6.1-full/Telegram/SourceFiles/settings/settings_information.cpp
@@ -78,9 +78,7 @@
 	int _outerIndex = 0;
 
 	Ui::SlideWrap<Ui::SettingsButton> *_addAccount = nullptr;
-	base::flat_map<
-		not_null<Main::Account*>,
-		base::unique_qptr<Ui::SettingsButton>> _watched;
+	base::flat_map<not_null<Main::Account*>, Ui::SettingsButton*> _watched;
 
 	base::unique_qptr<Ui::PopupMenu> _contextMenu;
 	std::unique_ptr<Ui::VerticalLayoutReorder> _reorder;
@@ -730,7 +728,7 @@
 				order.reserve(inner->count());
 				for (auto i = 0; i < inner->count(); i++) {
 					for (const auto &[account, button] : _watched) {
-						if (button.get() == inner->widgetAt(i)) {
+						if (button == inner->widgetAt(i)) {
 							order.push_back(account->session().uniqueId());
 						}
 					}
@@ -769,11 +767,11 @@
 					account,
 					std::move(activate));
 			};
-			button.reset(inner->add(MakeAccountButton(
+			button = inner->add(MakeAccountButton(
 				inner,
 				_controller,
 				account,
-				std::move(callback))));
+				std::move(callback)));
 		}
 	}
 	inner->resizeToWidth(_outer->width());