fix crash

This commit is contained in:
Benjamin Reis 2018-05-23 16:01:16 +02:00
parent b97ee0988b
commit fd9cf1e387
2 changed files with 12 additions and 6 deletions

View file

@ -165,7 +165,14 @@ typedef enum { ContactsAll, ContactsLinphone, ContactsMAX } ContactsCategory;
UIChatCreateCollectionViewCell *cell = (UIChatCreateCollectionViewCell *)[_collectionView dequeueReusableCellWithReuseIdentifier:uri forIndexPath:indexPath];
cell.controller = self;
cell.uri = uri;
LinphoneAddress *addr = linphone_address_new(uri.UTF8String);
LinphoneAddress *addr = NULL;
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
if (cfg && linphone_proxy_config_is_phone_number(cfg, uri.UTF8String)) {
char *phone = linphone_proxy_config_normalize_phone_number(cfg, uri.UTF8String);
addr = linphone_proxy_config_normalize_sip_uri(cfg, phone);
ms_free(phone);
} else
addr = linphone_address_new(uri.UTF8String);
cell = [cell initWithName:[FastAddressBook displayNameForAddress:addr]];
linphone_address_unref(addr);
return cell;

View file

@ -494,11 +494,10 @@
// since user wants to escape plus, we assume it expects to have phone
// numbers by default
if (addr && cfg) {
if (linphone_proxy_config_get_dial_escape_plus(cfg) && linphone_proxy_config_is_phone_number(cfg, normvalue))
linphone_address_set_username(addr, normvalue);
else if (linphone_proxy_config_is_phone_number(cfg, value.UTF8String))
linphone_address_set_username(addr, value.UTF8String);
}
const char *username = linphone_proxy_config_get_dial_escape_plus(cfg) ? normvalue : value.UTF8String;
if (linphone_proxy_config_is_phone_number(cfg, username))
linphone_address_set_username(addr, username);
}
return addr;
}