Skip to content

Commit e99c688

Browse files
committed
C++: Demonstrate ArrayExpr FP
1 parent 88a39d9 commit e99c688

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/NonConstantFormat.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@
1818
| test.cpp:85:12:85:16 | hello | The format string argument to printf should be constant to prevent security issues and other potential errors. |
1919
| test.cpp:90:12:90:18 | ++ ... | The format string argument to printf should be constant to prevent security issues and other potential errors. |
2020
| test.cpp:107:12:107:24 | new[] | The format string argument to printf should be constant to prevent security issues and other potential errors. |
21+
| test.cpp:142:10:142:20 | access to array | The format string argument to printf should be constant to prevent security issues and other potential errors. |

cpp/ql/test/query-tests/Likely Bugs/Format/NonConstantFormat/test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,11 @@ void another_func(void) {
133133
printf("Hello, World\n"); // GOOD
134134
printf(gettext("Hello, World\n")); // GOOD
135135
}
136+
137+
void set_value_of(int *i);
138+
139+
void print_ith_message() {
140+
int i;
141+
set_value_of(&i);
142+
printf(messages[i], 1U); // GOOD [FALSE POSITIVE]
143+
}

0 commit comments

Comments
 (0)