strtok()
returns a pointer to the next token or
NULL
. If it returns
NULL
then the call to
strlen()
will fail because you have passed it an invalid pointer. Your code should read:
cp = strtok(NULL, hash);
if (cp == NULL)
Note that you have similar bugs elsewhere in your code; you must check that the return from
strtok()
is non-null before passing it to any other function.