Fixed invalid read(s) in vcard.cc

This commit is contained in:
Sylvain Berfini 2016-06-28 11:05:39 +02:00
parent 04e2b9f4b5
commit d1f2b1d28f

View file

@ -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<belcard::BelCardImpp> 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<belcard::BelCardPhoneNumber> 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) {