[cfe-commits] r94785 - /cfe/trunk/lib/Sema/SemaChecking.cpp

Ted Kremenek kremenek at apple.com
Thu Jan 28 17:43:31 PST 2010


Author: kremenek
Date: Thu Jan 28 19:43:31 2010
New Revision: 94785

URL: http://llvm.org/viewvc/llvm-project?rev=94785&view=rev
Log:
Alternate format string checking: check if the number of format specifiers exceeds the number of arguments.

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=94785&r1=94784&r2=94785&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jan 28 19:43:31 2010
@@ -1418,6 +1418,18 @@
     return true;
   }
   
+  
+  // The remaining checks depend on the data arguments.
+  if (HasVAListArg)
+    return true;
+  
+  if (NumConversions > NumDataArgs) {
+    S.Diag(getLocationOfByte(CS.getStart()),
+           diag::warn_printf_insufficient_data_args)
+      << getFormatRange();    
+    // Don't do any more checking.
+    return false;
+  }
 
   return true;
 }





More information about the cfe-commits mailing list