diff --git a/clang/lib/StaticAnalyzer/Checkers/OpenHarmony/PrintSensitiveInfoChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/OpenHarmony/PrintSensitiveInfoChecker.cpp index 9647f99a4c5f2f1cb8de22268e9cd32a2b2f8cc5..7fa15c77d81cefee8abab4884ed300be5d593ee6 100644 --- a/clang/lib/StaticAnalyzer/Checkers/OpenHarmony/PrintSensitiveInfoChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/OpenHarmony/PrintSensitiveInfoChecker.cpp @@ -120,6 +120,8 @@ const VarDecl *PrintSensitiveInfoChecker::GetVarDeclFromExpr(const Expr *E) cons } string PrintSensitiveInfoChecker::GetCurrentCalleeName(const CallExpr *CE) const { + assert(CE); + assert(CE->getDirectCallee()); return CE->getDirectCallee()->getNameInfo().getName().getAsString(); } @@ -198,7 +200,7 @@ void PrintSensitiveInfoChecker::checkPreStmt(const BinaryOperator *binary, Check } void PrintSensitiveInfoChecker::checkPreStmt(const CallExpr *call, CheckerContext &c) const { - if (call == nullptr) { + if (!call || !call->getDirectCallee()) { return; } string funcName = GetCurrentCalleeName(call); @@ -248,6 +250,9 @@ void PrintSensitiveInfoChecker::saveVardeclStateForBo(const Expr *lhs, const Exp } if (isa(rhs)) { const CallExpr *call = llvm::dyn_cast_or_null(rhs); + if (!call || !call->getDirectCallee()) { + return; + } string funcName = GetCurrentCalleeName(call); if (m_sensitive_func_set.find(convertStrToLowerCase(funcName)) != m_sensitive_func_set.end()) { ProgramStateRef state = c.getState(); @@ -272,6 +277,9 @@ void PrintSensitiveInfoChecker::saveVardeclStateForDeclStmt(const DeclStmt *ds, if (isa(expr)) { const CallExpr *call = llvm::dyn_cast_or_null(expr); + if (!call || !call->getDirectCallee()) { + return; + } string funcName = GetCurrentCalleeName(call); if (m_sensitive_func_set.find(convertStrToLowerCase(funcName)) != m_sensitive_func_set.end()) { ProgramStateRef state = c.getState();