diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index f4487a7ea..ca93e7665 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -710,7 +710,7 @@ LinphoneFriend * linphone_friend_list_find_friend_by_uri(const LinphoneFriendLis LinphoneFriend * linphone_friend_list_find_friend_by_ref_key(const LinphoneFriendList *list, const char *ref_key) { bctbx_iterator_t* it = bctbx_map_cchar_find_key(list->friends_map, (void*)ref_key); - if (it == bctbx_map_cchar_end(list->friends_map)) { + if (bctbx_iterator_cchar_equals(it, bctbx_map_cchar_end(list->friends_map))) { return NULL; } bctbx_pair_t *pair = bctbx_iterator_cchar_get_pair(it); diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index 33c9faf91..c3af05ae7 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -814,6 +814,19 @@ end: linphone_friend_unref(lf); linphone_core_manager_destroy(manager); } +static void find_friend_by_ref_key_empty_list_test(void) { + LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE); + LinphoneFriendList *lfl = linphone_core_get_default_friend_list(manager->lc); + LinphoneFriend *lf2; + lf2 = linphone_friend_list_find_friend_by_ref_key(lfl, "totorefkey"); + BC_ASSERT_PTR_NULL(lf2); + if (lf2) { + linphone_friend_unref(lf2); + goto end; + } +end: + linphone_core_manager_destroy(manager); +} test_t vcard_tests[] = { TEST_NO_TAG("Import / Export friends from vCards", linphone_vcard_import_export_friends_test), @@ -833,7 +846,8 @@ test_t vcard_tests[] = { TEST_NO_TAG("CardDAV integration", carddav_integration), TEST_NO_TAG("CardDAV multiple synchronizations", carddav_multiple_sync), TEST_NO_TAG("CardDAV client to server and server to client sync", carddav_server_to_client_and_client_to_sever_sync), - TEST_NO_TAG("Find friend by ref key", find_friend_by_ref_key_test) + TEST_NO_TAG("Find friend by ref key", find_friend_by_ref_key_test), + TEST_NO_TAG("Find friend by ref key in empty list", find_friend_by_ref_key_empty_list_test) };