File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Buildless Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1
1
| tests.c:7:18:7:18 | 1 | This format specifier for type 'char *' does not match the argument type 'int'. |
2
+ | tests.c:29:27:29:27 | 1 | This format specifier for type 'char *' does not match the argument type 'int'. |
Original file line number Diff line number Diff line change @@ -10,3 +10,21 @@ void f(UNKNOWN_CHAR * str) {
10
10
fprintf (0 , "%s" , "" ); // GOOD
11
11
printf ("%s" , str ); // GOOD - erroneous type is ignored
12
12
}
13
+
14
+ #define va_list void*
15
+ #define va_start (x , y ) x = 0;
16
+ #define va_arg (x , y ) ((y)x)
17
+ #define va_end (x )
18
+ int vprintf (const char * format , va_list args );
19
+
20
+ int my_printf (const char * format , ...) {
21
+ va_list args ;
22
+ va_start (args , format );
23
+ int result = vprintf (format , args );
24
+ va_end (args );
25
+ return result ;
26
+ }
27
+
28
+ void linker_awareness_test () {
29
+ my_printf ("%s%d" , "" , 1 ); // GOOD
30
+ }
Original file line number Diff line number Diff line change
1
+ #define va_list void*
2
+ #define va_start (x , y ) x = 0;
3
+ #define va_arg (x , y ) ((y)x)
4
+ #define va_end (x )
5
+
6
+ int vprintf (const char * format , va_list args );
7
+
8
+ int my_printf (void * p ,const char * format , ...) {
9
+ va_list args ;
10
+ va_start (args , format );
11
+ int result = vprintf (format , args );
12
+ va_end (args );
13
+ return result ;
14
+ }
You can’t perform that action at this time.
0 commit comments