diff --git a/coreapi/vcard.cc b/coreapi/vcard.cc index e85948582..1aa7dd17a 100644 --- a/coreapi/vcard.cc +++ b/coreapi/vcard.cc @@ -134,13 +134,17 @@ void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_addres void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address) { if (!vCard) return; + shared_ptr impp; for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) { const char *value = (*it)->getValue().c_str(); if (strcmp(value, sip_address) == 0) { - vCard->belCard->removeImpp(*it); + impp = *it; break; } } + if (impp) { + vCard->belCard->removeImpp(impp); + } } void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) { @@ -180,13 +184,17 @@ void linphone_vcard_add_phone_number(LinphoneVcard *vCard, const char *phone) { void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone) { if (!vCard) return; + shared_ptr tel; for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) { const char *value = (*it)->getValue().c_str(); if (strcmp(value, phone) == 0) { - vCard->belCard->removePhoneNumber(*it); + tel = *it; break; } } + if (tel) { + vCard->belCard->removePhoneNumber(tel); + } } bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) {