Skip to content

Commit dda7069

Browse files
committed
CPP: Look for destructors in the template.
1 parent 76a5072 commit dda7069

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

cpp/ql/src/jsf/4.10 Classes/AV Rule 79.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ predicate unreleasedResource(Resource r, Expr acquire, File f, int acquireLine)
162162

163163
// check that any destructor for this class has a block; if it doesn't,
164164
// we must be missing information.
165-
and forall(Destructor d |
166-
d = r.getDeclaringType().getAMember() and
165+
and forall(Class c, Destructor d |
166+
r.getDeclaringType().isConstructedFrom*(c) and
167+
d = c.getAMember() and
167168
not d.isCompilerGenerated() and
168169
not d.isDefaulted() and
169170
not d.isDeleted() |

cpp/ql/test/query-tests/jsf/4.10 Classes/AV Rule 79/AV Rule 79.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
| ExternalOwners.cpp:49:3:49:20 | ... = ... | Resource a is acquired by class MyScreen but not released anywhere in this class. |
1212
| ListDelete.cpp:21:3:21:21 | ... = ... | Resource first is acquired by class MyThingColection but not released anywhere in this class. |
1313
| NoDestructor.cpp:23:3:23:20 | ... = ... | Resource n is acquired by class MyClass5 but not released anywhere in this class. |
14-
| NoDestructor.cpp:75:3:75:21 | ... = ... | Resource ptr is acquired by class TemplateWithDestructor<int *> but not released anywhere in this class. |
1514
| PlacementNew.cpp:36:3:36:36 | ... = ... | Resource p1 is acquired by class MyTestForPlacementNew but not released anywhere in this class. |
1615
| SelfRegistering.cpp:25:3:25:24 | ... = ... | Resource side is acquired by class MyOwner but not released anywhere in this class. |
1716
| Variants.cpp:25:3:25:13 | ... = ... | Resource f is acquired by class MyClass4 but not released anywhere in this class. |

cpp/ql/test/query-tests/jsf/4.10 Classes/AV Rule 79/NoDestructor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class TemplateWithDestructor
7272
{
7373
public:
7474
TemplateWithDestructor(int len) {
75-
ptr = new char[len]; // GOOD [FALSE POSITIVE]
75+
ptr = new char[len]; // GOOD
7676
}
7777

7878
~TemplateWithDestructor()

0 commit comments

Comments
 (0)