Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4cf92e

Browse files
author
Robert Marsh
committed
C++: Improve non-member iterator operator detection
1 parent 10005dd commit d4cf92e

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

  • cpp/ql/src/semmle/code/cpp/models/implementations

cpp/ql/src/semmle/code/cpp/models/implementations/Iterator.qll

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,27 @@ class Iterator extends Type {
5959

6060
private predicate calledWithIteratorArgument(Operator op, int index) {
6161
exists(Type t |
62-
t = op.getACallToThisFunction().getArgument(index).getUnspecifiedType()
63-
|
64-
t instanceof Iterator
65-
or
66-
t.(ReferenceType).getBaseType() instanceof Iterator
62+
t =
63+
op
64+
.getACallToThisFunction()
65+
.getArgument(index)
66+
.getExplicitlyConverted()
67+
.getType()
68+
.stripTopLevelSpecifiers()
69+
|
70+
t instanceof Iterator
71+
or
72+
t.(ReferenceType).getBaseType() instanceof Iterator
6773
)
6874
}
75+
6976
/**
7077
* A non-member prefix `operator*` function for an iterator type.
7178
*/
7279
class IteratorPointerDereferenceOperator extends Operator, TaintFunction {
7380
IteratorPointerDereferenceOperator() {
7481
this.hasName("operator*") and
75-
this.getACallToThisFunction().getArgument(0).getFullyConverted().getUnderlyingType() instanceof
76-
Iterator
82+
calledWithIteratorArgument(this, 0)
7783
}
7884

7985
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {

0 commit comments

Comments
 (0)