github-vet / github-vet/rangeloop-pointer-findings
sagap/Peerster: hw3/part1/gossiper2_backend/gossiper2.go; 22 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [sagap/Peerster](https://www.github.com/sagap/Peerster) at [hw3/part1/gossiper2_backend/gossiper2.go](https://github.com/sagap/Peerster/blob/8b4ac1aec5674313c070f74dd8ae3f38c456b94e/hw3/part1/gossiper2_backend/gossiper2.go#L342-L363)
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.
> reference to msg was used in a composite literal at line 359
[Click here to see the code in its original context.](https://github.com/sagap/Peerster/blob/8b4ac1aec5674313c070f74dd8ae3f38c456b94e/hw3/part1/gossiper2_backend/gossiper2.go#L342-L363)
Click here to show the 22 line(s) of Go which triggered the analyzer.
```go
for msg := range gossiper.msgChnPriv {
if strings.Compare(msg.Text, "") == 0 || strings.Compare(msg.Dest, "") == 0 { // in case someone does not include Dest or Test
return
}
if strings.Compare(msg.Origin, "") == 0 {
msg.Origin = gossiper.origin
}
if strings.Compare(msg.Dest, gossiper.origin) == 0 {
fmt.Print("PRIVATE: ", msg.Origin, ":", msg.HopLimit, ":", msg.Text, "\n")
gossiper.mupriv.Lock()
gossiper.privateList[time.Now()] = msg
gossiper.mupriv.Unlock()
} else {
msg.HopLimit--
if msg.HopLimit == 0 {
return
} else {
messageToSend := messaging.GossipPacket{nil, nil, &msg, nil, nil}
go gossiper.sendPrivateMessages(messageToSend, msg.Dest)
}
}
}
```
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: 8b4ac1aec5674313c070f74dd8ae3f38c456b94e
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.