mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
CPP: Fix for virtual method calls.
This commit is contained in:
@@ -96,13 +96,19 @@ private predicate exprReleases(Expr e, Expr released, string kind) {
|
||||
) or exists(Function f, int arg |
|
||||
// `e` is a call to a function that releases one of it's parameters,
|
||||
// and `released` is the corresponding argument
|
||||
e.(FunctionCall).getTarget() = f and
|
||||
(
|
||||
e.(FunctionCall).getTarget() = f or
|
||||
e.(FunctionCall).getTarget().(MemberFunction).getAnOverridingFunction*() = f
|
||||
) and
|
||||
e.(FunctionCall).getArgument(arg) = released and
|
||||
exprReleases(_, exprOrDereference(f.getParameter(arg).getAnAccess()), kind)
|
||||
) or exists(Function f, ThisExpr innerThis |
|
||||
// `e` is a call to a method that releases `this`, and `released`
|
||||
// is the object that is called
|
||||
e.(FunctionCall).getTarget() = f and
|
||||
(
|
||||
e.(FunctionCall).getTarget() = f or
|
||||
e.(FunctionCall).getTarget().(MemberFunction).getAnOverridingFunction*() = f
|
||||
) and
|
||||
e.(FunctionCall).getQualifier() = exprOrDereference(released) and
|
||||
innerThis.getEnclosingFunction() = f and
|
||||
exprReleases(_, innerThis, kind)
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
| DeleteThis.cpp:56:3:56:24 | ... = ... | Resource ptr10 is acquired by class MyClass3 but not released anywhere in this class. |
|
||||
| DeleteThis.cpp:58:3:58:24 | ... = ... | Resource ptr12 is acquired by class MyClass3 but not released anywhere in this class. |
|
||||
| DeleteThis.cpp:60:3:60:24 | ... = ... | Resource ptr14 is acquired by class MyClass3 but not released anywhere in this class. |
|
||||
| DeleteThis.cpp:111:3:111:20 | ... = ... | Resource b is acquired by class MyClass7 but not released anywhere in this class. |
|
||||
| DeleteThis.cpp:112:3:112:20 | ... = ... | Resource c is acquired by class MyClass7 but not released anywhere in this class. |
|
||||
| ExternalOwners.cpp:49:3:49:20 | ... = ... | Resource a is acquired by class MyScreen but not released anywhere in this class. |
|
||||
| ListDelete.cpp:21:3:21:21 | ... = ... | Resource first is acquired by class MyThingColection but not released anywhere in this class. |
|
||||
| NoDestructor.cpp:23:3:23:20 | ... = ... | Resource n is acquired by class MyClass5 but not released anywhere in this class. |
|
||||
|
||||
@@ -108,8 +108,8 @@ public:
|
||||
MyClass7()
|
||||
{
|
||||
a = new MyClass5(); // GOOD
|
||||
b = new MyClass5(); // GOOD [FALSE POSITIVE]
|
||||
c = new MyClass6(); // GOOD [FALSE POSITIVE]
|
||||
b = new MyClass5(); // GOOD
|
||||
c = new MyClass6(); // GOOD
|
||||
}
|
||||
|
||||
~MyClass7()
|
||||
|
||||
Reference in New Issue
Block a user