Skip to content

Commit bb521d7

Browse files
authored
Merge pull request github#13665 from MathiasVP/fix-join-in-isUse
C++: Fix join in `isUse`
2 parents 14caaf1 + 3bbe954 commit bb521d7

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

cpp/ql/src/Critical/UseAfterFree.ql

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,24 @@ module ParameterSinks {
135135
}
136136
}
137137

138-
predicate isUse(DataFlow::Node n, Expr e) {
139-
isUse0(n, e)
140-
or
141-
exists(CallInstruction call, int i, InitializeParameterInstruction init |
142-
n.asOperand().getDef().getUnconvertedResultExpression() = e and
143-
init = ParameterSinks::getAnAlwaysDereferencedParameter() and
144-
call.getArgumentOperand(i) = n.asOperand() and
145-
init.hasIndex(i) and
146-
init.getEnclosingFunction() = call.getStaticCallTarget()
147-
)
138+
module IsUse {
139+
private import semmle.code.cpp.ir.dataflow.internal.DataFlowImplCommon
140+
141+
predicate isUse(DataFlow::Node n, Expr e) {
142+
isUse0(n, e)
143+
or
144+
exists(CallInstruction call, InitializeParameterInstruction init |
145+
n.asOperand().getDef().getUnconvertedResultExpression() = e and
146+
pragma[only_bind_into](init) = ParameterSinks::getAnAlwaysDereferencedParameter() and
147+
viableParamArg(call, DataFlow::instructionNode(init), n) and
148+
pragma[only_bind_out](init.getEnclosingFunction()) =
149+
pragma[only_bind_out](call.getStaticCallTarget())
150+
)
151+
}
148152
}
149153

154+
import IsUse
155+
150156
/**
151157
* `dealloc1` is a deallocation expression, `e` is an expression that dereferences a
152158
* pointer, and the `(dealloc1, e)` pair should be excluded by the `FlowFromFree` library.

0 commit comments

Comments
 (0)