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

robjporter/go-functions2: system/config/config.go; 9 LoC

Open
#12,942 0 comments 0 reactions 0 assignees View on GitHub
fresh tiny
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [robjporter/go-functions2](https://www.github.com/robjporter/go-functions2) at [system/config/config.go](https://github.com/robjporter/go-functions2/blob/31a5e41334a2e662843bb6c9e438a9669334d2d5/system/config/config.go#L301-L309)

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 304 may store a reference to src_v

[Click here to see the code in its original context.](https://github.com/robjporter/go-functions2/blob/31a5e41334a2e662843bb6c9e438a9669334d2d5/system/config/config.go#L301-L309)

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

```go
for k, src_v := range src_map {
dst_v, ok3 := dst_map[k]
if ok3 {
merge(&dst_v, &src_v)
dst_map[k] = dst_v
} else {
dst_map[k] = src_v
}
}

```

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 {
"(merge, 2)" -> {"(unmarshal, 2)";}
"(unmarshal, 2)" -> {"(document, 2)";}
"(document, 2)" -> {}
}

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: 31a5e41334a2e662843bb6c9e438a9669334d2d5

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in system/config/config.go at lines 301-309 and inspect the merge call and its unmarshal and document paths. Determine whether the reference to src_v can outlive the range iteration and whether the analyzer finding is a bug, mitigated, or desirable behavior. Classify the issue using the repository's contribution guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.