github-vet / github-vet/rangeloop-pointer-findings
dedis/student_18_pairingcosi: cothority/network/net.go; 27 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [dedis/student_18_pairingcosi](https://www.github.com/dedis/student_18_pairingcosi) at [cothority/network/net.go](https://github.com/dedis/student_18_pairingcosi/blob/6861571d1b17e5d829159b9ced5f2e477a030b2b/cothority/network/net.go#L266-L292)
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 addr used in defer or goroutine at line 269
[Click here to see the code in its original context.](https://github.com/dedis/student_18_pairingcosi/blob/6861571d1b17e5d829159b9ced5f2e477a030b2b/cothority/network/net.go#L266-L292)
Click here to show the 27 line(s) of Go which triggered the analyzer.
```go
for i, addr := range st.serverIdentity.Addresses {
log.Lvl3("Starting to listen on", addr)
go func() {
err = st.TCPHost.listen(addr, receiver)
// The listening is over
if err == nil || err == ErrClosed || err == ErrEOF {
return
}
st.TCPHost.listeningPort <- -1
}()
port := <-st.TCPHost.listeningPort
if port > 0 {
// If the port we asked for is '0', we need to
// update the address.
if strings.HasSuffix(addr, ":0") {
log.Lvl3("Got port", port)
addr = strings.TrimRight(addr, "0") +
strconv.Itoa(port)
st.serverIdentity.Addresses[i] = addr
st.lockAddress.Lock()
st.workingAddress = addr
st.lockAddress.Unlock()
}
return nil
}
err = fmt.Errorf("Couldn't open address %s", addr)
}
```
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: 6861571d1b17e5d829159b9ced5f2e477a030b2b
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.