r179228 - [analyzer] Fix a crash in SyntaxCString checker when given a custom strncat.
Anna Zaks
ganna at apple.com
Wed Apr 10 15:06:29 PDT 2013
Author: zaks
Date: Wed Apr 10 17:06:29 2013
New Revision: 179228
URL: http://llvm.org/viewvc/llvm-project?rev=179228&view=rev
Log:
[analyzer] Fix a crash in SyntaxCString checker when given a custom strncat.
Fixes PR13476
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
cfe/trunk/test/Analysis/cstring-syntax-cxx.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp?rev=179228&r1=179227&r2=179228&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp Wed Apr 10 17:06:29 2013
@@ -101,6 +101,8 @@ public:
// - strncat(dst, src, sizeof(dst) - 1);
// - strncat(dst, src, sizeof(dst));
bool WalkAST::containsBadStrncatPattern(const CallExpr *CE) {
+ if (CE->getNumArgs() != 3)
+ return false;
const Expr *DstArg = CE->getArg(0);
const Expr *SrcArg = CE->getArg(1);
const Expr *LenArg = CE->getArg(2);
Modified: cfe/trunk/test/Analysis/cstring-syntax-cxx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cstring-syntax-cxx.cpp?rev=179228&r1=179227&r2=179228&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/cstring-syntax-cxx.cpp (original)
+++ cfe/trunk/test/Analysis/cstring-syntax-cxx.cpp Wed Apr 10 17:06:29 2013
@@ -15,3 +15,8 @@ void test(X a, X b) {
X c = a + b;
}
+// Ensure we don't crash on custom-defined strncat.
+char strncat ();
+int main () {
+ return strncat ();
+}
\ No newline at end of file
More information about the cfe-commits
mailing list