mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Merge pull request #15120 from MathiasVP/fix-joins-in-av-rule-79
C++: Fix joins in `cpp/resource-not-released-in-destructor`
This commit is contained in:
@@ -328,6 +328,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
|
||||
MetricFunction getMetrics() { result = this }
|
||||
|
||||
/** Holds if this function calls the function `f`. */
|
||||
pragma[nomagic]
|
||||
predicate calls(Function f) { this.calls(f, _) }
|
||||
|
||||
/**
|
||||
@@ -338,10 +339,6 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
|
||||
exists(FunctionCall call |
|
||||
call.getEnclosingFunction() = this and call.getTarget() = f and call = l
|
||||
)
|
||||
or
|
||||
exists(DestructorCall call |
|
||||
call.getEnclosingFunction() = this and call.getTarget() = f and call = l
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if this function accesses a function or variable or enumerator `a`. */
|
||||
|
||||
@@ -126,13 +126,13 @@ class Resource extends MemberVariable {
|
||||
}
|
||||
|
||||
private predicate calledFromDestructor(Function f) {
|
||||
f instanceof Destructor and f.getDeclaringType() = this.getDeclaringType()
|
||||
pragma[only_bind_into](f) instanceof Destructor and
|
||||
f.getDeclaringType() = this.getDeclaringType()
|
||||
or
|
||||
exists(Function mid, FunctionCall fc |
|
||||
exists(Function mid |
|
||||
this.calledFromDestructor(mid) and
|
||||
fc.getEnclosingFunction() = mid and
|
||||
fc.getTarget() = f and
|
||||
f.getDeclaringType() = this.getDeclaringType()
|
||||
mid.calls(f) and
|
||||
pragma[only_bind_out](f.getDeclaringType()) = pragma[only_bind_out](this.getDeclaringType())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user