From befbdada932360372a39599e9ea19fc2ca3e6866 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 25 Feb 2016 16:30:55 +0100 Subject: [PATCH] Fixed Segfault when trying to store friend's vcard in db before it was added to a friendlist --- coreapi/friend.c | 5 +++++ gtk/friendlist.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/coreapi/friend.c b/coreapi/friend.c index 5319d3c41..5e448c66f 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -1133,6 +1133,11 @@ void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf) { return; } + if (!lf || !lf->friend_list) { + ms_warning("Either the friend or the friend list is null, skipping..."); + return; + } + if (lf->friend_list->storage_id == 0) { ms_warning("Trying to add a friend in db, but friend list isn't, let's do that first"); linphone_core_store_friends_list_in_db(lc, lf->friend_list); diff --git a/gtk/friendlist.c b/gtk/friendlist.c index 3d51e0459..5a7c29c46 100644 --- a/gtk/friendlist.c +++ b/gtk/friendlist.c @@ -440,7 +440,7 @@ static void icon_press_handler(GtkEntry *entry){ lf=linphone_core_get_friend_by_address(linphone_gtk_get_core(),uri); ms_free(uri); if (lf==NULL) - lf=linphone_friend_new(); + lf=linphone_core_create_friend(linphone_gtk_get_core()); if (lf!=NULL){ linphone_friend_set_address(lf,addr); linphone_gtk_show_contact(lf, w); @@ -752,7 +752,7 @@ void linphone_gtk_contact_ok(GtkWidget *button){ const gchar *name,*uri; LinphoneAddress* friend_address; if (lf==NULL){ - lf=linphone_friend_new(); + lf=linphone_core_create_friend(linphone_gtk_get_core()); if (linphone_gtk_get_ui_config_int("use_subscribe_notify",1)==1){ show_presence=FALSE; allow_presence=FALSE;