From 038343812c665d3ead7287c3f3cadf176ca311a6 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Thu, 2 Jun 2022 12:13:54 +0200 Subject: [PATCH] Avoid potential crash in canAdmniEphemeral chatroom function --- Classes/ChatConversationView.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 0851dc958..11d9adf8d 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -1651,6 +1651,8 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog -(BOOL) canAdminEphemeral:(LinphoneChatRoom *)cr { + if (!cr) return FALSE; + // If ephemeral mode is DeviceManaged, then we don't need to check anything else return (linphone_chat_room_params_get_ephemeral_mode(linphone_chat_room_get_current_params(cr)) == LinphoneChatRoomEphemeralModeDeviceManaged) || ( linphone_chat_room_has_capability(cr, LinphoneChatRoomCapabilitiesEphemeral) && linphone_chat_room_params_get_ephemeral_mode(linphone_chat_room_get_current_params(cr)) == LinphoneChatRoomEphemeralModeAdminManaged && linphone_participant_is_admin(linphone_chat_room_get_me(cr))); @@ -1694,7 +1696,7 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return (_chatRoom && [self canAdminEphemeral:_chatRoom]) ? 3 : 2; + return [self canAdminEphemeral:_chatRoom] ? 3 : 2; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {