mirror of
https://github.com/github/codeql.git
synced 2026-04-21 06:55:31 +02:00
Merge pull request #18200 from github/calumgrant/bmn/wrong-type-format-args2
C++: Fix more FPs with extraction errors on cpp/wrong-type-format-arguments
This commit is contained in:
@@ -170,7 +170,7 @@ where
|
||||
) and
|
||||
not arg.isAffectedByMacro() and
|
||||
not arg.isFromUninstantiatedTemplate(_) and
|
||||
not actual.getUnspecifiedType() instanceof ErroneousType and
|
||||
not actual.stripType() instanceof ErroneousType and
|
||||
not arg.(Call).mayBeFromImplicitlyDeclaredFunction()
|
||||
select arg,
|
||||
"This format specifier for type '" + expected.getName() + "' does not match the argument type '" +
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The "Wrong type of arguments to formatting function" query (`cpp/wrong-type-format-argument`) no longer produces results when an argument type has an extraction error.
|
||||
@@ -3,9 +3,10 @@
|
||||
int printf(const char * format, ...);
|
||||
int fprintf();
|
||||
|
||||
void f() {
|
||||
void f(UNKNOWN_CHAR * str) {
|
||||
printf("%s", 1); // BAD
|
||||
printf("%s", implicit_function()); // GOOD - we should ignore the type
|
||||
sprintf(0, "%s", ""); // GOOD
|
||||
fprintf(0, "%s", ""); // GOOD
|
||||
printf("%s", str); // GOOD - erroneous type is ignored
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user