mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Merge pull request #1162 from geoffw0/rnr-open
CPP: Fix Resource not released in destructor FP
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user