summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-09-27 22:25:01 +0000
committerAnna Zaks <ganna@apple.com>2011-09-27 22:25:01 +0000
commit0070c6d4dbdf81147b69b8f721ea1b39e9421bb2 (patch)
treec272aab7ec8158aa0c13a6e1465846ea910de638
parentc63af1b7b637d6ede4f824b02a675082c2fbbcf6 (diff)
downloadbcm5719-llvm-0070c6d4dbdf81147b69b8f721ea1b39e9421bb2.tar.gz
bcm5719-llvm-0070c6d4dbdf81147b69b8f721ea1b39e9421bb2.zip
Fix a crash in MallocOverflowSecurityChecker. Patch by Lei Zhang.
llvm-svn: 140648
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp2
-rw-r--r--clang/test/Analysis/malloc-overflow.cpp11
2 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
index 983252c7710..0f6b621bf7c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
@@ -244,6 +244,8 @@ void MallocOverflowSecurityChecker::checkASTCodeBody(const Decl *D,
// Get the name of the callee. If it's a builtin, strip off the prefix.
IdentifierInfo *FnInfo = FD->getIdentifier();
+ if (!FnInfo)
+ return;
if (FnInfo->isStr ("malloc") || FnInfo->isStr ("_MALLOC")) {
if (TheCall->getNumArgs() == 1)
diff --git a/clang/test/Analysis/malloc-overflow.cpp b/clang/test/Analysis/malloc-overflow.cpp
new file mode 100644
index 00000000000..c1ac6be4b02
--- /dev/null
+++ b/clang/test/Analysis/malloc-overflow.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.MallocOverflow -verify %s
+
+class A {
+public:
+ A& operator<<(const A &a);
+};
+
+void f() {
+ A a = A(), b = A();
+ a << b;
+}
OpenPOWER on IntegriCloud