]> granicus.if.org Git - clang/commitdiff
Eliminates an assert in the strncpy/strncat checker caused by not validating a cast...
authorLenny Maiorani <lenny@colorado.edu>
Thu, 28 Apr 2011 18:59:43 +0000 (18:59 +0000)
committerLenny Maiorani <lenny@colorado.edu>
Thu, 28 Apr 2011 18:59:43 +0000 (18:59 +0000)
This fixes Bugzilla #9806.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130422 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/CStringChecker.cpp

index 8e9c7899b0df63830c45fab8f0844517c0016cbe..534b887f3b26c3148bd05ddf3709cd6dbbc3051f 100644 (file)
@@ -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;