diff --git a/coreapi/friend.c b/coreapi/friend.c index 583bf9ef9c9e1169b2559f83c45b380bbce92952..508adddd76ff2deee79be7f0776dbdd23f530273 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -108,13 +108,16 @@ static int friend_compare(const void * a, const void * b) { } static LinphoneFriendPresence * find_presence_model_for_uri_or_tel(const LinphoneFriend *lf, const char *uri_or_tel) { - bctbx_list_t *iterator = lf->presence_models; - LinphoneAddress *uri_or_tel_addr = linphone_core_interpret_url(lf->lc, uri_or_tel); + bctbx_list_t *iterator = NULL; + LinphoneAddress *uri_or_tel_addr = NULL; LinphoneFriendPresence *result=NULL; if (!lf->lc) { ms_warning("Cannot find uri of tel [%s] from friend [%p] because not associated to any Linphone core object",uri_or_tel,lf); return NULL; } + iterator = lf->presence_models; + uri_or_tel_addr = linphone_core_interpret_url(lf->lc, uri_or_tel); + while (uri_or_tel_addr && iterator) { LinphoneFriendPresence *lfp = (LinphoneFriendPresence *)bctbx_list_get_data(iterator); LinphoneAddress *lfp_addr = linphone_core_interpret_url(lf->lc, lfp->uri_or_tel); diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index 0a70a22c15daa75716e1f197410045ffa88b1211..9ec1ea3943734171b156e717c5ae7eb99a1aef02 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -706,6 +706,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) { const bctbx_list_t *elem; if (ref_key == NULL) return NULL; + if (list == NULL) return NULL; for (elem = list->friends; elem != NULL; elem = bctbx_list_next(elem)) { LinphoneFriend *lf = (LinphoneFriend *)bctbx_list_get_data(elem); if ((lf->refkey != NULL) && (strcmp(lf->refkey, ref_key) == 0)) return lf;