I have written a small program on Mac OS X but I am getting the following error in the following function :
Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000 0x00007fff99b359c4 in strstr ()
/*
* attrvalue(): parse an attribute value pair.
*
* takes a string of the form "ATTRIBUTE = VALUE" and returns the atrribute name
* and value as seperate strings
*
*/
int
attrvalue(char *entry, char **attr, char **value)
{
char *copy;
char *p;
if (!entry || *entry == '\0')
return 1;
copy = strdup(entry);
*attr = strtok(copy, "=");
*value = strtok(NULL, "\n");
/* strip training whitespace from attr and value */
p = strstr(*attr, " ");
if(p)
*p = '\0';
p = strstr(*value, " ");
if(p)
*p = '\0';
return (0);
}
Any idea what is wrong with this function here?
Thanks.