You shouldn't be freeing the pointer strtok returns at all.