If separa is NULL, path[first_part_len] was a '\0' to begin with, and you've just broken path's termination !