From 6b25584c6f0154c476024e35df83074251d7daaf Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Thu, 28 Nov 2019 16:11:43 +0100 Subject: [PATCH] fix crash when cancel edit contact with an empty phone number --- Classes/ContactDetailsView.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index 5be8586d4..e2ad291bc 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -437,9 +437,13 @@ static UICompositeViewDescription *compositeDescription = nil; nbSipAd++; } } - while (_contact.phones.count > 0 && - _contact.phones[0] != NULL) { - [_contact removePhoneNumberAtIndex:0]; + while (_contact.phones.count > 0) { + if (_contact.phones[0] != NULL && ![_contact.phones[0] isEqualToString:@" "]) { + [_contact removePhoneNumberAtIndex:0]; + } else { + // remove empty index + [_contact.phones removeObjectAtIndex:0]; + } } NSInteger nbPhone = 0; if (_tmpContact.phones != NULL) {