diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-01-29 01:43:31 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-01-29 01:43:31 +0000 |
commit | da51f0d136df131a0137c0ec1069fb586d8a296a (patch) | |
tree | 176e862680ca12c2a8d6a096b048c0b218c81c77 /lib/Sema/SemaChecking.cpp | |
parent | d7a3f01a5109807b4fad48a7ab75fa806b8b899d (diff) |
Alternate format string checking: check if the number of format specifiers exceeds the number of arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94785 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index d856a2323a..81c309be51 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -1418,6 +1418,18 @@ CheckPrintfHandler::HandleFormatSpecifier(const analyze_printf::FormatSpecifier 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; } |