fix some null ptr error

analyzed by clang