aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/CStringChecker.cpp')
-rw-r--r--lib/StaticAnalyzer/Checkers/CStringChecker.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 8e9c7899b0..534b887f3b 100644
--- a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1017,8 +1017,15 @@ void CStringChecker::evalStrcpyCommon(CheckerContext &C, const CallExpr *CE,
const Expr *lenExpr = CE->getArg(2);
SVal lenVal = state->getSVal(lenExpr);
+ // Cast the length to a NonLoc SVal. If it is not a NonLoc then give up.
NonLoc *strLengthNL = dyn_cast<NonLoc>(&strLength);
+ if (!strLengthNL)
+ return;
+
+ // Cast the max length to a NonLoc SVal. If it is not a NonLoc then give up.
NonLoc *lenValNL = dyn_cast<NonLoc>(&lenVal);
+ if (!lenValNL)
+ return;
QualType cmpTy = C.getSValBuilder().getContext().IntTy;
const GRState *stateTrue, *stateFalse;