Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) standard C memory issue

Check the return value of strtok.

In your code here

locTok = strtok(NULL, "..");
posL[pCount].stop = atoi(locTok); //ERROR IS SHOWN HERE

strtok is returning a NULL pointer and according to documentation,

A null pointer is returned if there are no tokens left to retrieve.

which matches my original guess that because the address code is 0x0 there’s a NULL pointer deference somewhere.

Obviously, the following call to atoi is expecting a non-NULL pointer and crashes.

Leave a Comment