From 66715b35bc3513af18aa9259e697ed8f1e0829f3 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 18 Jan 2017 10:21:50 +0100 Subject: [PATCH] Fixed crash if friend doesn't have a core yet while creating a vcard --- coreapi/friend.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/coreapi/friend.c b/coreapi/friend.c index e0dce2831..c949e5da4 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -1068,6 +1068,8 @@ void linphone_friend_set_vcard(LinphoneFriend *fr, LinphoneVcard *vcard) { bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) { LinphoneVcard *vcard = NULL; + LinphoneCore *lc = NULL; + bool_t skip = FALSE; if (!fr || !name) { ms_error("Friend or name is null"); @@ -1083,8 +1085,15 @@ bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) { } vcard = linphone_vcard_new(); - bool_t skip = 1 - lp_config_get_int(fr->lc->config, "misc", "store_friends", 1); - linphone_vcard_set_skip_validation(vcard, skip); + + lc = fr->lc; + if (!lc && fr->friend_list) { + lc = fr->friend_list->lc; + } + if (lc) { + skip = 1 - lp_config_get_int(fr->lc->config, "misc", "store_friends", 1); + linphone_vcard_set_skip_validation(vcard, skip); + } linphone_vcard_set_full_name(vcard, name); linphone_friend_set_vcard(fr, vcard); return TRUE;