From 96d1fe336a06225ccb36dc9dcf00aca15b5e334a Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Sun, 2 Jul 2017 22:23:41 +0300
Subject: [PATCH] Fix assertion violation when editing an admin.

There is a possibility that an EditAdminBox will be shown for someone
who can't add admins right now (in case server says he can edit one).

In that case assertion about the admins checkbox is false and we fix
that. Currently server sometimes does return this flag by mistake.
---
 Telegram/SourceFiles/boxes/edit_participant_box.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/Telegram/SourceFiles/boxes/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/edit_participant_box.cpp
index 77a275278..402450f45 100644
--- a/Telegram/SourceFiles/boxes/edit_participant_box.cpp
+++ b/Telegram/SourceFiles/boxes/edit_participant_box.cpp
@@ -216,13 +216,15 @@ void EditAdminBox::prepare() {
 		addCheckbox(Flag::f_add_admins, lang(lng_rights_add_admins));
 	}
 
-	_aboutAddAdmins = addControl(object_ptr<Ui::FlatLabel>(this, st::boxLabel));
 	auto addAdmins = _checkboxes.find(Flag::f_add_admins);
-	t_assert(addAdmins != _checkboxes.end());
-	connect(addAdmins->second, &Ui::Checkbox::changed, this, [this] {
+	if (addAdmins != _checkboxes.end()) {
+		_aboutAddAdmins = addControl(object_ptr<Ui::FlatLabel>(this, st::boxLabel));
+		t_assert(addAdmins != _checkboxes.end());
+		connect(addAdmins->second, &Ui::Checkbox::changed, this, [this] {
+			refreshAboutAddAdminsText();
+		});
 		refreshAboutAddAdminsText();
-	});
-	refreshAboutAddAdminsText();
+	}
 
 	addButton(langFactory(lng_settings_save), [this] {
 		if (!_saveCallback) {