File tree Expand file tree Collapse file tree
cpp/ql/test/query-tests/Critical/NewFree Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22| test.cpp:182:3:182:22 | delete | This memory may have been allocated with '$@', not 'new'. | test.cpp:175:18:175:29 | new[] | new[] |
33| test.cpp:240:2:240:9 | delete | This memory may have been allocated with '$@', not 'new'. | test.cpp:228:7:228:17 | new[] | new[] |
44| test.cpp:295:2:295:11 | delete | This memory may have been allocated with '$@', not 'new'. | test.cpp:290:8:290:28 | new[] | new[] |
5+ | test.cpp:310:3:310:13 | delete | This memory may have been allocated with '$@', not 'new'. | test.cpp:304:18:304:29 | new[] | new[] |
Original file line number Diff line number Diff line change @@ -295,3 +295,45 @@ static void map_shutdown()
295295 delete map; // BAD: new[] -> delete
296296 map = 0 ;
297297}
298+
299+ // ---
300+
301+ class Test10
302+ {
303+ public:
304+ Test10 () : data(new char [10 ])
305+ {
306+ }
307+
308+ ~Test10 ()
309+ {
310+ delete data; // BAD: new[] -> delete
311+ }
312+
313+ char *data;
314+ };
315+
316+ class Test11
317+ {
318+ public:
319+ Test11 ()
320+ {
321+ data = new char [10 ];
322+ }
323+
324+ void resize (int size)
325+ {
326+ if (size > 0 )
327+ {
328+ delete [] data; // GOOD
329+ data = new char [size];
330+ }
331+ }
332+
333+ ~Test11 ()
334+ {
335+ delete data; // BAD: new[] -> delete [NOT DETECTED]
336+ }
337+
338+ char *data;
339+ };
You can’t perform that action at this time.
0 commit comments