mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
C++: Make specsAreKnown more accurate.
This commit is contained in:
@@ -900,6 +900,7 @@ class FormatLiteral extends Literal {
|
||||
*/
|
||||
int getNumArgNeeded(int n) {
|
||||
exists(this.getConvSpecOffset(n)) and
|
||||
exists(this.getConversionChar(n)) and
|
||||
result = count(int mode | hasFormatArgumentIndexFor(n, mode))
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,3 @@
|
||||
| test.c:39:3:39:8 | call to printf | Format expects 2 arguments but given 5 |
|
||||
| test.c:40:3:40:8 | call to printf | Format expects 2 arguments but given 4 |
|
||||
| test.c:41:3:41:8 | call to printf | Format expects 2 arguments but given 3 |
|
||||
| test.c:46:2:46:7 | call to printf | Format expects 1 arguments but given 2 |
|
||||
| test.c:47:2:47:7 | call to printf | Format expects 1 arguments but given 2 |
|
||||
| test.c:48:2:48:7 | call to printf | Format expects 1 arguments but given 2 |
|
||||
|
||||
@@ -43,7 +43,7 @@ void test(int i, const char *str)
|
||||
|
||||
printf("%@ %i %i", 1, 2); // GOOD
|
||||
|
||||
printf("%Y", 1, 2); // GOOD (unknown format character, this might be correct) [FALSE POSITIVE]
|
||||
printf("%1.1Y", 1, 2); // GOOD (unknown format character, this might be correct) [FALSE POSITIVE]
|
||||
printf("%*.*Y", 1, 2); // GOOD (unknown format character, this might be correct) [FALSE POSITIVE]
|
||||
printf("%Y", 1, 2); // GOOD (unknown format character, this might be correct)
|
||||
printf("%1.1Y", 1, 2); // GOOD (unknown format character, this might be correct)
|
||||
printf("%*.*Y", 1, 2); // GOOD (unknown format character, this might be correct)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user