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:222:9:222:12 | data | Memory pointed to by 'data' may have been previously freed $@ | test.cpp:223:5:223:8 | call to free | here |
11+ | test.cpp:223:10:223:13 | data | Memory pointed to by 'data' may have been previously freed $@ | test.cpp:223:5:223:8 | call to free | here |
12+ | test.cpp:234:9:234:12 | data | Memory pointed to by 'data' may have been previously freed $@ | test.cpp:230:5:230:8 | call to free | here |
Original file line number Diff line number Diff line change @@ -213,3 +213,24 @@ void regression_test_for_static_var_handling()
213213 data = (char *)malloc (100 *sizeof (char ));
214214 use (data); // GOOD
215215}
216+
217+ void test16 (int n, bool b) {
218+ char * data = NULL ;
219+ for (int i = 0 ; i < n; ++i) {
220+ if (b) data = (char *)malloc (10 * sizeof (char ));
221+ if (!b || data == NULL ) return ;
222+ use (data); // GOOD [FALSE POSITIVE]
223+ free (data); // GOOD [FALSE POSITIVE]
224+ }
225+ }
226+
227+ void test17 (int n, bool b) {
228+ char * data = (char *)malloc (10 );
229+ if (b) {
230+ free (data);
231+ }
232+
233+ if (!b) {
234+ use (data); // GOOD [FALSE POSITIVE]
235+ }
236+ }
You can’t perform that action at this time.
0 commit comments