github-vet / github-vet/rangeloop-pointer-findings
runningwild/pnf: core/network_mock.go; 21 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [runningwild/pnf](https://www.github.com/runningwild/pnf) at [core/network_mock.go](https://github.com/runningwild/pnf/blob/9f0493d70324cf43409c649d31b060006026d9c3/core/network_mock.go#L327-L347)
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.
> range-loop variable i used in defer or goroutine at line 343
[Click here to see the code in its original context.](https://github.com/runningwild/pnf/blob/9f0493d70324cf43409c649d31b060006026d9c3/core/network_mock.go#L327-L347)
Click here to show the 21 line(s) of Go which triggered the analyzer.
```go
for i := range hm.net.hosts {
if hm.net.hosts[i].id == rh.id {
for _, data := range hm.net.hosts[i].conn_data {
if data.remote_id == hm.id {
hm.net.host_mutex.Unlock()
return nil, errors.New("Tried to connect to an already connected network.")
}
}
err := hm.net.hosts[i].join(data)
if err != nil {
hm.net.host_mutex.Unlock()
return nil, err
}
c1, c2 := makeConnMockPair(hm, hm.net.hosts[i])
go func() {
hm.net.host_mutex.Unlock()
hm.net.hosts[i].new_conns <- c2
}()
return c1, nil
}
}
```
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: 9f0493d70324cf43409c649d31b060006026d9c3
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.