github-vet / github-vet/rangeloop-pointer-findings
tizz98/dnsleak: db.go; 37 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [tizz98/dnsleak](https://www.github.com/tizz98/dnsleak) at [db.go](https://github.com/tizz98/dnsleak/blob/4874595bdcadad1451edd5e2118cdd24ef0f9280/db.go#L55-L91)
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 key used in defer or goroutine at line 64
[Click here to see the code in its original context.](https://github.com/tizz98/dnsleak/blob/4874595bdcadad1451edd5e2118cdd24ef0f9280/db.go#L55-L91)
Click here to show the 37 line(s) of Go which triggered the analyzer.
```go
for _, key := range keys {
wg.Add(1)
go func(k string) {
defer wg.Done()
num, _ := strconv.Atoi(strings.Split(k, ".")[0])
keyResult := LookUpResult{Number: num}
addrs, err := db.conn.SMembers(key).Result()
if err != nil {
panic("unable to SMembers for key: " + err.Error())
}
for _, addr := range addrs {
res, err := client.LookUpIp(addr)
if err != nil {
logrus.WithError(err).Errorf("unable to lookup ip %s", addr)
res = nil // make sure it's nil
}
if res != nil && res.Bogon {
logrus.Warningf("bogon ip: %s", addr)
res = nil
}
keyResult.IPs = append(keyResult.IPs, LookUpResultIp{
Address: addr,
Info: res,
})
}
m.Lock()
results.Results = append(results.Results, keyResult)
m.Unlock()
}(key)
}
```
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: 4874595bdcadad1451edd5e2118cdd24ef0f9280
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.