From d45825823720856e5d3ac644e76818b49c350042 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 3 Feb 2016 15:26:07 +0100 Subject: [PATCH] Fixed segfault when manipulating friends with vcards without carddav configured --- coreapi/friendlist.c | 10 ++++++---- tester/vcard_tester.c | 4 ---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index b13ced1f5..f7501e2c4 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -451,11 +451,13 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie LinphoneVCard *lvc = linphone_friend_get_vcard(lf); if (lvc && linphone_vcard_get_uid(lvc)) { LinphoneCardDavContext *cdc = linphone_carddav_context_new(list); - cdc->sync_done_cb = carddav_done; - if (cdc->friend_list->cbs->sync_state_changed_cb) { - cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, LinphoneFriendListSyncStarted, NULL); + if (cdc) { + cdc->sync_done_cb = carddav_done; + if (cdc->friend_list->cbs->sync_state_changed_cb) { + cdc->friend_list->cbs->sync_state_changed_cb(cdc->friend_list, LinphoneFriendListSyncStarted, NULL); + } + linphone_carddav_delete_vcard(cdc, lf); } - linphone_carddav_delete_vcard(cdc, lf); } } diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index d425eb822..cf0dd5964 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -120,11 +120,7 @@ static void friends_migration(void) { BC_ASSERT_EQUAL(ms_list_size(friends), 3, int, "%d"); friends_from_db = linphone_core_fetch_friends_from_db(manager->lc, lfl); BC_ASSERT_EQUAL(ms_list_size(friends_from_db), 3, int, "%d"); - if (ms_list_size(friends_from_db) < 3) { - goto end; - } -end: friends_from_db = ms_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref); unlink(friends_db); ms_free(friends_db);