Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 2d4f17c

Browse files
author
Max Schaefer
committed
Ensure result inputs always have an entry node.
1 parent 4b56581 commit 2d4f17c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private class ResultInput extends FunctionInput, TInResult {
116116
|
117117
// if the result is assigned to an SSA variable, we want to propagate mutations backwards
118118
// through that variable
119-
exists(DataFlow::SsaNode ssa | ssa.getInit() = pred | result = ssa.(DataFlow::PostUpdateNode))
119+
exists(DataFlow::SsaNode ssa | ssa.getInit() = pred | result = ssa)
120120
or
121121
// otherwise the entry node is simply the result
122122
not exists(DataFlow::SsaNode ssa | ssa.getInit() = pred) and

ql/test/library-tests/semmle/go/dataflow/FunctionInputsAndOutputs/FunctionInput_getEntryNode.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@
2525
| result | main.go:53:2:53:22 | call to op2 | main.go:53:2:53:22 | call to op2 |
2626
| result | main.go:53:14:53:21 | call to bump | main.go:53:14:53:21 | call to bump |
2727
| result | tst2.go:10:9:10:26 | call to NewEncoder | tst2.go:10:9:10:26 | call to NewEncoder |
28+
| result | tst2.go:10:9:10:39 | call to Encode | tst2.go:10:2:10:4 | definition of err |
2829
| result | tst.go:9:17:9:33 | call to new | tst.go:9:2:9:12 | definition of bytesBuffer |
2930
| result 0 | main.go:51:2:51:14 | call to op | main.go:51:2:51:14 | call to op |
3031
| result 0 | main.go:53:2:53:22 | call to op2 | main.go:53:2:53:22 | call to op2 |
3132
| result 0 | main.go:53:14:53:21 | call to bump | main.go:53:14:53:21 | call to bump |
33+
| result 0 | main.go:54:10:54:15 | call to test | main.go:54:2:54:2 | definition of x |
34+
| result 0 | main.go:56:9:56:15 | call to test2 | main.go:56:2:56:2 | definition of x |
3235
| result 0 | tst2.go:10:9:10:26 | call to NewEncoder | tst2.go:10:9:10:26 | call to NewEncoder |
36+
| result 0 | tst2.go:10:9:10:39 | call to Encode | tst2.go:10:2:10:4 | definition of err |
3337
| result 0 | tst.go:9:17:9:33 | call to new | tst.go:9:2:9:12 | definition of bytesBuffer |
38+
| result 1 | main.go:54:10:54:15 | call to test | main.go:54:5:54:5 | definition of y |
39+
| result 1 | main.go:56:9:56:15 | call to test2 | main.go:56:5:56:5 | definition of y |

0 commit comments

Comments
 (0)