Skip to content

Commit 17077f3

Browse files
committed
Update OutParameter.getExitNode for implicit varargs slices
1 parent 39da26e commit 17077f3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

go/ql/lib/semmle/go/dataflow/FunctionInputsAndOutputs.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private class OutReceiver extends FunctionOutput, TOutReceiver {
282282
/**
283283
* A parameter of a function, viewed as an output.
284284
*
285-
* Note that slices passed to varargs parameters using `...` are not included, since in this
285+
* Note that slices passed to variadic parameters using `...` are not included, since in this
286286
* case it is ambiguous whether the output should be the slice itself or one of its elements.
287287
*/
288288
private class OutParameter extends FunctionOutput, TOutParameter {
@@ -300,9 +300,12 @@ private class OutParameter extends FunctionOutput, TOutParameter {
300300

301301
override DataFlow::Node getExitNode(DataFlow::CallNode c) {
302302
exists(DataFlow::Node arg |
303-
arg = getArgument(c, index) and
304-
// exclude slices passed to varargs parameters using `...` calls
303+
arg = c.getSyntacticArgument(index) and
304+
// exclude slices followed by `...` passed to variadic parameters
305305
not (c.hasEllipsis() and index = c.getNumArgument() - 1)
306+
or
307+
arg = c.(DataFlow::MethodCallNode).getReceiver() and
308+
index = -1
306309
|
307310
result.(DataFlow::PostUpdateNode).getPreUpdateNode() = arg
308311
)

0 commit comments

Comments
 (0)