Merge pull request #1162 from geoffw0/rnr-open

CPP: Fix Resource not released in destructor FP
This commit is contained in:
Jonas Jensen
2019-03-25 17:26:34 +01:00
committed by GitHub
3 changed files with 39 additions and 2 deletions

View File

@@ -12,5 +12,6 @@
| **Query** | **Expected impact** | **Change** |
|----------------------------|------------------------|------------------------------------------------------------------|
| Mismatching new/free or malloc/delete (`cpp/new-free-mismatch`) | Fewer false positive results | Fixed an issue where functions were being identified as allocation functions inappropriately. Also affects `cpp/new-array-delete-mismatch` and `cpp/new-delete-array-mismatch`. |
| Resource not released in destructor (`cpp/resource-not-released-in-destructor`) | Fewer false positive results | Resource allocation and deallocation functions are now determined more accurately. |
## Changes to QL libraries

View File

@@ -21,7 +21,7 @@ predicate acquireExpr(Expr acquire, string kind) {
exists(FunctionCall fc, Function f, string name |
fc = acquire and
f = fc.getTarget() and
name = f.getName() and
name = f.getQualifiedName() and
(
(
name = "fopen" and
@@ -47,7 +47,7 @@ predicate releaseExpr(Expr release, Expr resource, string kind) {
exists(FunctionCall fc, Function f, string name |
fc = release and
f = fc.getTarget() and
name = f.getName() and
name = f.getQualifiedName() and
(
(
name = "fclose" and

View File

@@ -73,3 +73,39 @@ public:
int *a, *b, *c;
};
class MyClass7
{
public:
MyClass7()
{
}
bool open()
{
// ...
}
void close()
{
// ...
}
};
class myClass7Test
{
public:
myClass7Test()
{
success = mc7.open(); // GOOD
}
~myClass7Test()
{
mc7.close();
}
private:
MyClass7 mc7;
bool success;
};