liblinphone: fix potential crash when interpretting URLs

This commit is contained in:
Gautier Pelloux-Prayer 2015-10-28 09:33:53 +01:00
parent 60bbcbc944
commit af1ff6a113
3 changed files with 15 additions and 9 deletions

View file

@ -40,10 +40,14 @@
}
}
// also add current entry, if not listed
const LinphoneAddress *addr = linphone_core_interpret_url([LinphoneManager getLc], filter.UTF8String);
char *uri = linphone_address_as_string(addr);
NSString *nsuri = [NSString stringWithUTF8String:uri];
ms_free(uri);
LinphoneAddress *addr = linphone_core_interpret_url([LinphoneManager getLc], filter.UTF8String);
NSString *nsuri = filter;
if (addr) {
char *uri = linphone_address_as_string(addr);
nsuri = [NSString stringWithUTF8String:uri];
ms_free(uri);
linphone_address_destroy(addr);
}
if (![_contacts containsObject:nsuri]) {
[_contacts insertObject:nsuri atIndex:0];
}

View file

@ -126,7 +126,8 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info
- (void)addCurrentContactContactField:(NSString *)address {
LinphoneAddress *linphoneAddress = linphone_core_interpret_url([LinphoneManager getLc], address.UTF8String);
NSString *username = [NSString stringWithUTF8String:linphone_address_get_username(linphoneAddress)];
NSString *username =
linphoneAddress ? [NSString stringWithUTF8String:linphone_address_get_username(linphoneAddress)] : address;
if (([username rangeOfString:@"@"].length > 0) &&
([[LinphoneManager instance] lpConfigBoolForKey:@"show_contacts_emails_preference"] == true)) {
@ -137,8 +138,9 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info
} else {
[_tableController addSipField:address];
}
linphone_address_destroy(linphoneAddress);
if (linphoneAddress) {
linphone_address_destroy(linphoneAddress);
}
[self setEditing:FALSE];
[[_tableController tableView] reloadData];
}

View file

@ -61,9 +61,9 @@
- (IBAction)onCallClick:(id)event {
LinphoneAddress *addr = linphone_core_interpret_url([LinphoneManager getLc], _addressLabel.text.UTF8String);
char *lAddress = linphone_address_as_string_uri_only(addr);
if (lAddress == NULL)
if (addr == NULL)
return;
char *lAddress = linphone_address_as_string_uri_only(addr);
NSString *displayName = [FastAddressBook displayNameForAddress:addr];
DialerView *view = VIEW(DialerView);