aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-02-15 02:12:00 +0000
committerAnna Zaks <ganna@apple.com>2012-02-15 02:12:00 +0000
commit1d6cc6a44182ef03a373ecd61505042eca3af906 (patch)
tree38e2c1554260a0e6f54fc4224799413c7727fef3 /lib/StaticAnalyzer/Checkers/MallocChecker.cpp
parent5677eafb01b64ca83f671f3aee9de103a04c2c76 (diff)
[analyzer] Malloc checker: make a bit safer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150556 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/MallocChecker.cpp')
-rw-r--r--lib/StaticAnalyzer/Checkers/MallocChecker.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 766de4b751..88a0613a78 100644
--- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -265,11 +265,14 @@ void MallocChecker::initIdentifierInfo(ASTContext &Ctx) const {
}
bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext &C) const {
- initIdentifierInfo(C);
+ if (!FD)
+ return false;
IdentifierInfo *FunI = FD->getIdentifier();
if (!FunI)
return false;
+ initIdentifierInfo(C);
+
// TODO: Add more here : ex: reallocf!
if (FunI == II_malloc || FunI == II_free || FunI == II_realloc ||
FunI == II_reallocf || FunI == II_calloc || FunI == II_valloc)
@@ -1006,7 +1009,8 @@ MallocChecker::checkRegionChanges(ProgramStateRef State,
return State;
llvm::SmallPtrSet<SymbolRef, 8> WhitelistedSymbols;
- const FunctionDecl *FD = (Call ? dyn_cast<FunctionDecl>(Call->getDecl()) : 0);
+ const FunctionDecl *FD = (Call ?
+ dyn_cast_or_null<FunctionDecl>(Call->getDecl()) :0);
// If it's a call which might free or reallocate memory, we assume that all
// regions (explicit and implicit) escaped. Otherwise, whitelist explicit