Alternate format string checking: check if the number of format specifiers exceeds the number of arguments.

llvm-svn: 94785
This commit is contained in:
Ted Kremenek 2010-01-29 01:43:31 +00:00
parent 559d89a02a
commit 9fcd8305c0
1 changed files with 12 additions and 0 deletions

View File

@ -1419,6 +1419,18 @@ CheckPrintfHandler::HandleFormatSpecifier(const analyze_printf::FormatSpecifier
}
// 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;
}