File tree Expand file tree Collapse file tree
cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77| test.cpp:170:6:170:9 | data | Memory pointed to by 'data' may have been previously freed $@ | test.cpp:165:2:165:5 | call to free | here |
88| test.cpp:193:6:193:9 | data | Memory pointed to by 'data' may have been previously freed $@ | test.cpp:191:3:191:6 | call to free | here |
99| test.cpp:201:6:201:6 | x | Memory pointed to by 'x' may have been previously freed $@ | test.cpp:200:2:200:9 | delete | here |
10+ | test.cpp:242:14:242:17 | data | Memory pointed to by 'data' may have been previously freed $@ | test.cpp:243:11:243:14 | call to free | here |
Original file line number Diff line number Diff line change @@ -234,3 +234,21 @@ void test17(int n, bool b) {
234234 use (data); // GOOD
235235 }
236236}
237+
238+ void test18 (int * array) {
239+ char * data = (char *)malloc (10 * sizeof (char ));
240+ for (int i = 0 ; i < 4 ; ++i) {
241+ int b = array[i];
242+ if (b) use (data); // BAD
243+ if (!b) free (data);
244+ }
245+ }
246+
247+ void test19 (int * array) {
248+ char * data = (char *)malloc (10 * sizeof (char ));
249+ int b = array[0 ];
250+ for (int i = 0 ; i < 4 ; ++i) {
251+ if (b) use (data); // GOOD
252+ if (!b) free (data);
253+ }
254+ }
You can’t perform that action at this time.
0 commit comments