]> granicus.if.org Git - clang/commitdiff
Add null check for malformed code.
authorTed Kremenek <kremenek@apple.com>
Thu, 11 Oct 2012 19:06:43 +0000 (19:06 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 11 Oct 2012 19:06:43 +0000 (19:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165733 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp

index 480088619cf1b3a9a412cd49ee572bc00dc46060..6a39ff003c0c146041b182f1e332bb5f247d97d3 100644 (file)
@@ -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<NonNullAttr>
          I = FDecl->specific_attr_begin<NonNullAttr>(),