Skip to content

Commit 1942402

Browse files
committed
C++: Test for erroneous string types
1 parent cc4382c commit 1942402

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
| tests.c:7:18:7:18 | 1 | This format specifier for type 'char *' does not match the argument type 'int'. |
2+
| tests.c:11:18:11:20 | str | This format specifier for type 'char *' does not match the argument type '<error-type> *'. |

cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Buildless/tests.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
int printf(const char * format, ...);
44
int fprintf();
55

6-
void f() {
6+
void f(UNKNOWN_CHAR * str) {
77
printf("%s", 1); // BAD
88
printf("%s", implicit_function()); // GOOD - we should ignore the type
99
sprintf(0, "%s", ""); // GOOD
1010
fprintf(0, "%s", ""); // GOOD
11+
printf("%s", str); // GOOD - erroneous type is ignored
1112
}

0 commit comments

Comments
 (0)