From: Ted Kremenek Date: Thu, 11 Oct 2012 19:06:43 +0000 (+0000) Subject: Add null check for malformed code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0234bfa2b03470b8ce379a7485e60ffa35c1d550;p=clang Add null check for malformed code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165733 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 480088619c..6a39ff003c 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -510,8 +510,11 @@ void Sema::checkCall(NamedDecl *FDecl, Expr **Args, // Refuse POD arguments that weren't caught by the format string // checks above. if (!HandledFormatString && CallType != VariadicDoesNotApply) - for (unsigned ArgIdx = NumProtoArgs; ArgIdx < NumArgs; ++ArgIdx) - variadicArgumentPODCheck(Args[ArgIdx], CallType); + for (unsigned ArgIdx = NumProtoArgs; ArgIdx < NumArgs; ++ArgIdx) { + // Args[ArgIdx] can be null in malformed code. + if (Expr *Arg = Args[ArgIdx]) + variadicArgumentPODCheck(Arg, CallType); + } for (specific_attr_iterator I = FDecl->specific_attr_begin(),