fix a bug of invoking destroy with null pointer.
this bug appears when an invalid character appears before
first node is created.