diff --git a/Classes/ContactDetailsTableViewController.m b/Classes/ContactDetailsTableViewController.m index 0b7f3bac5..1f89e971f 100644 --- a/Classes/ContactDetailsTableViewController.m +++ b/Classes/ContactDetailsTableViewController.m @@ -294,17 +294,19 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {ContactSe NSString* username = CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey); LinphoneAddress* address = linphone_core_interpret_url([LinphoneManager getLc] ,[username UTF8String]); - char* uri = linphone_address_as_string_uri_only(address); - CFStringRef keys[] = { kABPersonInstantMessageUsernameKey, kABPersonInstantMessageServiceKey}; - CFTypeRef values[] = { [NSString stringWithCString:uri encoding:[NSString defaultCStringEncoding]], [LinphoneManager instance].contactSipField }; - CFDictionaryRef lDict2 = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 2, NULL, NULL); - ABMultiValueReplaceValueAtIndex(lMap, lDict2, index); - if (!ABRecordSetValue(contact, kABPersonInstantMessageProperty, lMap, (CFErrorRef*)&error)) { - [LinphoneLogger log:LinphoneLoggerLog format:@"Can't set contact with value [%@] cause [%@]", value,[error localizedDescription]]; - } - CFRelease(lDict2); - linphone_address_destroy(address); - ms_free(uri); + if(address){ + char* uri = linphone_address_as_string_uri_only(address); + CFStringRef keys[] = { kABPersonInstantMessageUsernameKey, kABPersonInstantMessageServiceKey}; + CFTypeRef values[] = { [NSString stringWithCString:uri encoding:[NSString defaultCStringEncoding]], [LinphoneManager instance].contactSipField }; + CFDictionaryRef lDict2 = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 2, NULL, NULL); + ABMultiValueReplaceValueAtIndex(lMap, lDict2, index); + if (!ABRecordSetValue(contact, kABPersonInstantMessageProperty, lMap, (CFErrorRef*)&error)) { + [LinphoneLogger log:LinphoneLoggerLog format:@"Can't set contact with value [%@] cause [%@]", value,[error localizedDescription]]; + } + CFRelease(lDict2); + linphone_address_destroy(address); + ms_free(uri); + } } CFRelease(lMap); }