[cfe-commits] r140648 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp test/Analysis/malloc-overflow.cpp

Anna Zaks ganna at apple.com
Tue Sep 27 17:25:01 CDT 2011


Author: zaks
Date: Tue Sep 27 17:25:01 2011
New Revision: 140648

URL: http://llvm.org/viewvc/llvm-project?rev=140648&view=rev
Log:
Fix a crash in MallocOverflowSecurityChecker. Patch by Lei Zhang.

Added:
    cfe/trunk/test/Analysis/malloc-overflow.cpp
Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp?rev=140648&r1=140647&r2=140648&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp Tue Sep 27 17:25:01 2011
@@ -244,6 +244,8 @@
 
           // 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)

Added: cfe/trunk/test/Analysis/malloc-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc-overflow.cpp?rev=140648&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/malloc-overflow.cpp (added)
+++ cfe/trunk/test/Analysis/malloc-overflow.cpp Tue Sep 27 17:25:01 2011
@@ -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;
+}




More information about the cfe-commits mailing list