mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-30 09:49:26 +00:00
fix(friendlist): avoid memory leaks in linphone_friend_list_find_friend_by_ref_key
This commit is contained in:
parent
82c9fc9260
commit
df0f8cfa9c
2 changed files with 15 additions and 9 deletions
|
|
@ -800,15 +800,19 @@ LinphoneFriend * linphone_friend_list_find_friend_by_uri(const LinphoneFriendLis
|
|||
return result;
|
||||
}
|
||||
|
||||
LinphoneFriend * linphone_friend_list_find_friend_by_ref_key(const LinphoneFriendList *list, const char *ref_key) {
|
||||
if(list) {
|
||||
bctbx_iterator_t* it = bctbx_map_cchar_find_key(list->friends_map, ref_key);
|
||||
if (!bctbx_iterator_cchar_equals(it, bctbx_map_cchar_end(list->friends_map))) {
|
||||
LinphoneFriend *linphone_friend_list_find_friend_by_ref_key (const LinphoneFriendList *list, const char *ref_key) {
|
||||
LinphoneFriend *result = NULL;
|
||||
if (list) {
|
||||
bctbx_iterator_t *it = bctbx_map_cchar_find_key(list->friends_map, ref_key);
|
||||
bctbx_iterator_t *end = bctbx_map_cchar_end(list->friends_map);
|
||||
if (!bctbx_iterator_cchar_equals(it, end)) {
|
||||
bctbx_pair_t *pair = bctbx_iterator_cchar_get_pair(it);
|
||||
return (LinphoneFriend *)bctbx_pair_cchar_get_second(pair);
|
||||
result = (LinphoneFriend *)bctbx_pair_cchar_get_second(pair);
|
||||
}
|
||||
bctbx_iterator_cchar_delete(end);
|
||||
bctbx_iterator_cchar_delete(it);
|
||||
}
|
||||
return NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
LinphoneFriend * linphone_friend_list_find_friend_by_inc_subscribe (
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ static void friends_sqlite_store_lot_of_friends(void) {
|
|||
int ret;
|
||||
char *buf;
|
||||
char *friends_db = bc_tester_file("friends.db");
|
||||
|
||||
|
||||
unlink(friends_db);
|
||||
ret = sqlite3_open(friends_db, &db);
|
||||
bc_free(friends_db);
|
||||
|
|
@ -437,7 +437,7 @@ static void friends_sqlite_find_friend_in_lot_of_friends(void) {
|
|||
bctoolboxTimeSpec t1;
|
||||
bctoolboxTimeSpec t2;
|
||||
char *friends_db = bc_tester_file("friends.db");
|
||||
|
||||
|
||||
unlink(friends_db);
|
||||
ret = sqlite3_open(friends_db, &db);
|
||||
bc_free(friends_db);
|
||||
|
|
@ -951,7 +951,9 @@ static void find_friend_by_ref_key_test(void) {
|
|||
goto end;
|
||||
}
|
||||
addr = linphone_friend_get_address(lf2);
|
||||
BC_ASSERT_STRING_EQUAL(linphone_address_as_string_uri_only(addr), "sip:toto@sip.linphone.org");
|
||||
char *uri_addr = linphone_address_as_string_uri_only(addr);
|
||||
BC_ASSERT_STRING_EQUAL(uri_addr, "sip:toto@sip.linphone.org");
|
||||
bctbx_free(uri_addr);
|
||||
BC_ASSERT_EQUAL(lf2, lf, void*, "%p");
|
||||
end:
|
||||
linphone_friend_unref(lf);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue