From 627e8d8081e89eec948f0e5c75e2a953f6b5c74e Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 28 Oct 2015 09:39:43 +0100 Subject: [PATCH] liblinphone: fix potential crash when interpretting URLs --- Classes/ContactDetailsViewController.m | 6 ++++-- Classes/LinphoneManager.m | 6 ++++-- Classes/LinphoneUI/Base.lproj/UICallBar.xib | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Classes/ContactDetailsViewController.m b/Classes/ContactDetailsViewController.m index 7d03e6b0f..29c692297 100644 --- a/Classes/ContactDetailsViewController.m +++ b/Classes/ContactDetailsViewController.m @@ -150,7 +150,8 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info - (void)addCurrentContactContactField:(NSString *)address { LinphoneAddress *linphoneAddress = linphone_address_new(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)) { @@ -161,7 +162,8 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info } else { [tableController addSipField:address]; } - linphone_address_destroy(linphoneAddress); + if (linphoneAddress) + linphone_address_destroy(linphoneAddress); [self enableEdit:FALSE]; [[tableController tableView] reloadData]; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 0376b561f..fdcb4f478 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -961,8 +961,10 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char } else { if ([[LinphoneManager instance] lpConfigBoolForKey:@"show_contacts_emails_preference"] == true) { LinphoneAddress *linphoneAddress = linphone_address_new([address UTF8String]); - address = [NSString stringWithUTF8String:linphone_address_get_username(linphoneAddress)]; - linphone_address_destroy(linphoneAddress); + if (linphoneAddress) { + address = [NSString stringWithUTF8String:linphone_address_get_username(linphoneAddress)]; + linphone_address_destroy(linphoneAddress); + } } } if (address == nil) { diff --git a/Classes/LinphoneUI/Base.lproj/UICallBar.xib b/Classes/LinphoneUI/Base.lproj/UICallBar.xib index f76753d37..2fe10a1af 100644 --- a/Classes/LinphoneUI/Base.lproj/UICallBar.xib +++ b/Classes/LinphoneUI/Base.lproj/UICallBar.xib @@ -1,8 +1,8 @@ - + - +