A subset of my app users are reporting a crash. When I symbolicated one of their crash logs, I found the offending code to be the label read.
Here is the output from the crash log:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 CoreFoundation 0x33e5004e 0x33e4d000 + 12366
1 CoreFoundation 0x33e58cfc 0x33e4d000 + 48380
2 Mail my meeting 0x00002a9c -[Mail_my_meetingAppDelegate initPeople] Mail_my_meetingAppDelegate.m:136)
3 Mail my meeting 0x0000287a -[Mail_my_meetingAppDelegate application:didFinishLaunchingWithOptions:] (Mail_my_meetingAppDelegate.m:74)
And here is the the code, with line 136 being the last line:
NSString* finalName=[NSString stringWithFormat:@"%@%@%@",firstName,middleName,lastName];
NSString *phoneNumber = nil;
ABMultiValueRef phoneNumbers1 = ABRecordCopyValue(person,kABPersonPhoneProperty);
if (ABMultiValueGetCount(phoneNumbers1) > 0) {
CFIndex j;
for (j=0; j < ABMultiValueGetCount(phoneNumbers1); j++) {
CFStringRef label = ABMultiValueCopyLabelAtIndex(phoneNumbers1, j);
I can't understand how this last line could cause a crash, because I validate that it is less than the count, and it starts at zero.
This is driving me a bit crazy, so any ideas at all are welcome!