[cfe-commits] r150556 - /cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Anna Zaks ganna at apple.com
Tue Feb 14 18:12:01 PST 2012


Author: zaks
Date: Tue Feb 14 20:12:00 2012
New Revision: 150556

URL: http://llvm.org/viewvc/llvm-project?rev=150556&view=rev
Log:
[analyzer] Malloc checker: make a bit safer.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=150556&r1=150555&r2=150556&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Tue Feb 14 20:12:00 2012
@@ -265,11 +265,14 @@
 }
 
 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 @@
     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





More information about the cfe-commits mailing list