diff options
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp index 0f6b621bf7..cf5501a4ac 100644 --- a/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp @@ -118,9 +118,12 @@ private: ASTContext &Context; bool isIntZeroExpr(const Expr *E) const { - return (E->getType()->isIntegralOrEnumerationType() - && E->isEvaluatable(Context) - && E->EvaluateAsInt(Context) == 0); + if (!E->getType()->isIntegralOrEnumerationType()) + return false; + llvm::APSInt Result; + if (E->EvaluateAsInt(Result, Context)) + return Result == 0; + return false; } void CheckExpr(const Expr *E_p) { @@ -263,4 +266,3 @@ void MallocOverflowSecurityChecker::checkASTCodeBody(const Decl *D, void ento::registerMallocOverflowSecurityChecker(CheckerManager &mgr) { mgr.registerChecker<MallocOverflowSecurityChecker>(); } - |