fix clang sa issue for potential derefernce of null pointer