Skip to content

Commit b2974ba

Browse files
committed
C++: Factor body of isSink into its own predicate.
1 parent b201fd0 commit b2974ba

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cpp/ql/src/experimental/Security/CWE/CWE-416/IteratorToExpiredContainer.ql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@
1111
* external/cwe/cwe-664
1212
*/
1313

14-
// IMPORTANT: This query does not currently find anything since it relies on extractor and analysis improvements that hasn't yet been released
1514
import cpp
1615
import semmle.code.cpp.ir.IR
1716
import semmle.code.cpp.dataflow.new.DataFlow
1817
import semmle.code.cpp.models.implementations.StdContainer
1918
import semmle.code.cpp.models.implementations.StdMap
2019
import semmle.code.cpp.models.implementations.Iterator
2120

21+
private predicate tempToDestructorSink(DataFlow::Node sink, CallInstruction call) {
22+
call = sink.asOperand().(ThisArgumentOperand).getCall() and
23+
call.getStaticCallTarget() instanceof Destructor
24+
}
25+
2226
/**
2327
* A configuration to track flow from a temporary variable to the qualifier of
2428
* a destructor call
@@ -28,9 +32,7 @@ module TempToDestructorConfig implements DataFlow::ConfigSig {
2832
source.asInstruction().(VariableAddressInstruction).getIRVariable() instanceof IRTempVariable
2933
}
3034

31-
predicate isSink(DataFlow::Node sink) {
32-
sink.asOperand().(ThisArgumentOperand).getCall().getStaticCallTarget() instanceof Destructor
33-
}
35+
predicate isSink(DataFlow::Node sink) { tempToDestructorSink(sink, _) }
3436
}
3537

3638
module TempToDestructorFlow = DataFlow::Global<TempToDestructorConfig>;

0 commit comments

Comments
 (0)