mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
CPP: Add a test of a Shutdown / Clear method.
This commit is contained in:
@@ -17,3 +17,5 @@
|
||||
| Variants.cpp:65:3:65:17 | ... = ... | Resource a is acquired by class MyClass6 but not released anywhere in this class. |
|
||||
| Variants.cpp:66:3:66:36 | ... = ... | Resource b is acquired by class MyClass6 but not released anywhere in this class. |
|
||||
| Variants.cpp:67:3:67:41 | ... = ... | Resource c is acquired by class MyClass6 but not released anywhere in this class. |
|
||||
| Wrapped.cpp:46:3:46:22 | ... = ... | Resource ptr2 is acquired by class Wrapped2 but not released anywhere in this class. |
|
||||
| Wrapped.cpp:59:3:59:22 | ... = ... | Resource ptr4 is acquired by class Wrapped2 but not released anywhere in this class. |
|
||||
|
||||
@@ -37,3 +37,34 @@ public:
|
||||
private:
|
||||
char *ptr1, *ptr2, *ptr3;
|
||||
};
|
||||
|
||||
class Wrapped2
|
||||
{
|
||||
public:
|
||||
Wrapped2(int len) {
|
||||
ptr1 = new char[len]; // GOOD
|
||||
ptr2 = new char[len]; // BAD: not released in destructor
|
||||
|
||||
Init(len);
|
||||
}
|
||||
|
||||
~Wrapped2()
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
void Init(int len)
|
||||
{
|
||||
ptr3 = new char[len]; // GOOD
|
||||
ptr4 = new char[len]; // BAD: not released in destructor
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
delete [] ptr1;
|
||||
delete [] ptr3;
|
||||
}
|
||||
|
||||
private:
|
||||
char *ptr1, *ptr2, *ptr3, *ptr4;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user