Skip to content

Commit 6b0ae0f

Browse files
committed
CPP: Remove unned argument from use-after-free
1 parent 2860c0c commit 6b0ae0f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

cpp/ql/src/Critical/UseAfterFree.ql

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ private predicate externalCallNeverDereferences(FormattingFunctionCall call, int
2929
)
3030
}
3131

32-
predicate isUse0(DataFlow::Node n, Expr e) {
33-
e = n.asExpr() and
34-
not isFree(n, _, _) and
32+
predicate isUse0(Expr e) {
33+
not isFree(_, e, _) and
3534
(
3635
e = any(PointerDereferenceExpr pde).getOperand()
3736
or
@@ -57,7 +56,7 @@ module ParameterSinks {
5756
import semmle.code.cpp.ir.ValueNumbering
5857

5958
predicate flowsToUse(DataFlow::Node n) {
60-
isUse0(n, _)
59+
isUse0(n.asExpr())
6160
or
6261
exists(DataFlow::Node succ |
6362
flowsToUse(succ) and
@@ -90,7 +89,7 @@ module ParameterSinks {
9089
) {
9190
pragma[only_bind_out](source.asParameter()) = pragma[only_bind_out](init.getParameter()) and
9291
paramToUse(source, sink) and
93-
isUse0(sink, _)
92+
isUse0(sink.asExpr())
9493
}
9594

9695
private InitializeParameterInstruction getAnAlwaysDereferencedParameter0() {
@@ -139,7 +138,7 @@ module IsUse {
139138
private import semmle.code.cpp.ir.dataflow.internal.DataFlowImplCommon
140139

141140
predicate isUse(DataFlow::Node n, Expr e) {
142-
isUse0(n, e)
141+
isUse0(e) and n.asExpr() = e
143142
or
144143
exists(CallInstruction call, InitializeParameterInstruction init |
145144
n.asOperand().getDef().getUnconvertedResultExpression() = e and

0 commit comments

Comments
 (0)