From 234f86cf4e783784b4b02508ed4991203f67ed8c Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Fri, 28 Nov 2014 17:00:56 +0100 Subject: [PATCH] Fix crash in Contacts when adding a contact. This was a bad refactoring --- Classes/ContactDetailsTableViewController.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Classes/ContactDetailsTableViewController.m b/Classes/ContactDetailsTableViewController.m index abaaaa2d4..9e929611c 100644 --- a/Classes/ContactDetailsTableViewController.m +++ b/Classes/ContactDetailsTableViewController.m @@ -426,12 +426,17 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {ContactSe ABPropertyID property = [self propertyIDForSection:contactSections[section]]; if( property != kABInvalidPropertyType ){ ABMultiValueRef lMap = ABRecordCopyValue(contact, property); - NSInteger index = ABMultiValueGetIndexForIdentifier(lMap, [entry identifier]); - CFTypeRef valueRef = ABMultiValueCopyValueAtIndex(lMap, index); + NSInteger index = ABMultiValueGetIndexForIdentifier(lMap, [entry identifier]); + CFTypeRef valueRef = ABMultiValueCopyValueAtIndex(lMap, index); + CFTypeRef toRelease = valueRef; + if (property == kABPersonInstantMessageProperty ) { + // when we query the instanteMsg property we get a dictionary instead of a value + valueRef = CFDictionaryGetValue(valueRef, kABPersonInstantMessageUsernameKey); + } if(![(NSString*) valueRef length]) { [self removeEntry:tableview path:[NSIndexPath indexPathForRow:row inSection:section] animated:animated]; } - CFRelease(valueRef); + CFRelease(toRelease); CFRelease(lMap); }