github-vet / github-vet/rangeloop-pointer-findings

better0332/ivega: decode/decode.go; 12 LoC

Open
#14,551 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [better0332/ivega](https://www.github.com/better0332/ivega) at [decode/decode.go](https://github.com/better0332/ivega/blob/1da13b0d5b347c4e065982b10fa874b7c758cb29/decode/decode.go#L311-L322)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.

> function call at line 314 may store a reference to vv

[Click here to see the code in its original context.](https://github.com/better0332/ivega/blob/1da13b0d5b347c4e065982b10fa874b7c758cb29/decode/decode.go#L311-L322)

Click here to show the 12 line(s) of Go which triggered the analyzer.

```go
for i, vv := range v {
switch vv.(type) {
case map[string]interface{}, []interface{}:
d.parseInterface(org, &vv, pre)
default:
var key string
if pre != nil {
key = pre.key
}
d.decode(vv, &node{JSONARRAY, pre, key, &jsonArray{org, v, i}})
}
}

```

Click here to show extra information the analyzer produced.

```
The following graphviz dot graph describes paths through the callgraph that could lead to a function which writes a pointer argument:
digraph G {
"(parseInterface, 3)" -> {}
}

No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: 1da13b0d5b347c4e065982b10fa874b7c758cb29

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with decode/decode.go lines 311-322 and inspect parseInterface to understand whether the range variable vv can be retained. Review the analyzer's classification guidance, then decide whether this is a Bug, Mitigated, or Desirable Behavior and leave the corresponding reaction on the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devtools
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.