From 6395c65febde8523a5dffb2ccc21193db60eca5c Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 24 Jan 2017 16:27:49 +0100 Subject: [PATCH] fix crash when removing a friend if such friend wasn't in the map. --- coreapi/friendlist.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index 6c48520d1..f00727ffe 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -581,7 +581,10 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie list->friends = bctbx_list_erase_link(list->friends, elem); if(lf->refkey) { bctbx_iterator_t * it = bctbx_map_cchar_find_key(list->friends_map, lf->refkey); - bctbx_map_cchar_erase(list->friends_map, it); + if (!bctbx_iterator_cchar_equals(it, bctbx_map_cchar_end(list->friends_map))){ + linphone_friend_unref((LinphoneFriend*)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it))); + bctbx_map_cchar_erase(list->friends_map, it); + } } lf->friend_list = NULL;