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

Skip to content

Commit d2b8d83

Browse files
committed
Avoid using getTarget() as it may not exist
Try to also deal with the case that we are calling a function through a variable that it has been assigned to.
1 parent 40eab18 commit d2b8d83

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

go/ql/lib/semmle/go/dataflow/internal/DataFlowDispatch.qll

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,6 @@ class ArgumentPosition extends int {
134134
pragma[inline]
135135
predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) { ppos = apos }
136136

137-
private predicate isInterfaceMethod(Method c) {
138-
c.getReceiverBaseType().getUnderlyingType() instanceof InterfaceType
139-
}
140-
141137
/**
142138
* Holds if `call` is passing `arg` to param `p` in any circumstance except passing
143139
* a receiver parameter to a concrete method.
@@ -149,9 +145,8 @@ predicate golangSpecificParamArgFilter(
149145
// Interface methods calls may be passed strictly to that exact method's model receiver:
150146
arg.getPosition() != -1
151147
or
152-
exists(Function callTarget | callTarget = call.getNode().(DataFlow::CallNode).getTarget() |
153-
not isInterfaceMethod(callTarget)
154-
or
155-
callTarget = p.getCallable().asSummarizedCallable().asFunction()
156-
)
148+
p instanceof DataFlow::SummarizedParameterNode
149+
or
150+
not call.getNode().(DataFlow::CallNode).getReceiver().getType().getUnderlyingType() instanceof
151+
InterfaceType
157152
}

0 commit comments

Comments
 (0)