diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 766de4b75125..88a0613a78f5 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/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 WhitelistedSymbols; - const FunctionDecl *FD = (Call ? dyn_cast(Call->getDecl()) : 0); + const FunctionDecl *FD = (Call ? + dyn_cast_or_null(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