mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
CPP: Add test cases.
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
| test.cpp:182:3:182:22 | delete | This memory may have been allocated with '$@', not 'new'. | test.cpp:175:18:175:29 | new[] | new[] |
|
||||
| test.cpp:240:2:240:9 | delete | This memory may have been allocated with '$@', not 'new'. | test.cpp:228:7:228:17 | new[] | new[] |
|
||||
| test.cpp:295:2:295:11 | delete | This memory may have been allocated with '$@', not 'new'. | test.cpp:290:8:290:28 | new[] | new[] |
|
||||
| test.cpp:310:3:310:13 | delete | This memory may have been allocated with '$@', not 'new'. | test.cpp:304:18:304:29 | new[] | new[] |
|
||||
|
||||
@@ -295,3 +295,45 @@ static void map_shutdown()
|
||||
delete map; // BAD: new[] -> delete
|
||||
map = 0;
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
class Test10
|
||||
{
|
||||
public:
|
||||
Test10() : data(new char[10])
|
||||
{
|
||||
}
|
||||
|
||||
~Test10()
|
||||
{
|
||||
delete data; // BAD: new[] -> delete
|
||||
}
|
||||
|
||||
char *data;
|
||||
};
|
||||
|
||||
class Test11
|
||||
{
|
||||
public:
|
||||
Test11()
|
||||
{
|
||||
data = new char[10];
|
||||
}
|
||||
|
||||
void resize(int size)
|
||||
{
|
||||
if (size > 0)
|
||||
{
|
||||
delete [] data; // GOOD
|
||||
data = new char[size];
|
||||
}
|
||||
}
|
||||
|
||||
~Test11()
|
||||
{
|
||||
delete data; // BAD: new[] -> delete [NOT DETECTED]
|
||||
}
|
||||
|
||||
char *data;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user