Commit 43a62dc8 authored by Erwan Croze's avatar Erwan Croze 👋🏻

Fixing memory leaks in friendlist

parent af5f102e
......@@ -634,10 +634,13 @@ 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);
if (!bctbx_iterator_cchar_equals(it, bctbx_map_cchar_end(list->friends_map))){
bctbx_iterator_t * end = bctbx_map_cchar_end(list->friends_map);
if (!bctbx_iterator_cchar_equals(it, end)){
linphone_friend_unref((LinphoneFriend*)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it)));
bctbx_map_cchar_erase(list->friends_map, it);
}
if (it) bctbx_iterator_cchar_delete(it);
if (end) bctbx_iterator_cchar_delete(end);
}
phone_numbers = linphone_friend_get_phone_numbers(lf);
......@@ -647,14 +650,17 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
const char *uri = linphone_friend_phone_number_to_sip_uri(lf, number);
if(uri) {
bctbx_iterator_t * it = bctbx_map_cchar_find_key(list->friends_map_uri, uri);
if (!bctbx_iterator_cchar_equals(it, bctbx_map_cchar_end(list->friends_map_uri))){
bctbx_iterator_t * end = bctbx_map_cchar_end(list->friends_map_uri);
if (!bctbx_iterator_cchar_equals(it, end)){
linphone_friend_unref((LinphoneFriend*)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it)));
bctbx_map_cchar_erase(list->friends_map_uri, it);
}
bctbx_iterator_cchar_delete(it);
if (it) bctbx_iterator_cchar_delete(it);
if (end) bctbx_iterator_cchar_delete(end);
}
iterator = bctbx_list_next(iterator);
}
if (phone_numbers) bctbx_list_free(phone_numbers);
addresses = linphone_friend_get_addresses(lf);
iterator = (bctbx_list_t *)addresses;
......@@ -663,13 +669,16 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
char *uri = linphone_address_as_string_uri_only(lfaddr);
if(uri) {
bctbx_iterator_t * it = bctbx_map_cchar_find_key(list->friends_map_uri, uri);
if (!bctbx_iterator_cchar_equals(it, bctbx_map_cchar_end(list->friends_map_uri))){
bctbx_iterator_t * end = bctbx_map_cchar_end(list->friends_map_uri);
if (!bctbx_iterator_cchar_equals(it, end)){
linphone_friend_unref((LinphoneFriend*)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it)));
bctbx_map_cchar_erase(list->friends_map_uri, it);
}
bctbx_iterator_cchar_delete(it);
if (it) bctbx_iterator_cchar_delete(it);
if (end) bctbx_iterator_cchar_delete(end);
ms_free(uri);
}
iterator = bctbx_list_next(iterator);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment