diff options
-rw-r--r-- | lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp | 2 | ||||
-rw-r--r-- | test/Analysis/malloc-overflow.cpp | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp index 983252c771..0f6b621bf7 100644 --- a/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp +++ b/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/test/Analysis/malloc-overflow.cpp b/test/Analysis/malloc-overflow.cpp new file mode 100644 index 0000000000..c1ac6be4b0 --- /dev/null +++ b/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; +} |