fix a crash of null pointer