github-vet / github-vet/rangeloop-pointer-findings
square/beancounter: accounter/accounter.go; 19 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [square/beancounter](https://www.github.com/square/beancounter) at [accounter/accounter.go](https://github.com/square/beancounter/blob/22bd81ac6ce3b51fc2833e4ae79ef527989428ae/accounter/accounter.go#L190-L208)
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 hash is reassigned at line 205
[Click here to see the code in its original context.](https://github.com/square/beancounter/blob/22bd81ac6ce3b51fc2833e4ae79ef527989428ae/accounter/accounter.go#L190-L208)
Click here to show the 19 line(s) of Go which triggered the analyzer.
```go
for hash, tx := range a.transactions {
for _, txin := range tx.vin {
prev, exists := a.transactions[txin.prevHash]
if !exists {
continue
}
if int(txin.index) >= len(prev.vout) {
panic("prev index > vouts")
}
if prev.vout[txin.index].ours {
balance -= prev.vout[txin.index].value
if prev.vout[txin.index].spentBy != nil {
// sanity check: an output can only be spent by one transaction.
log.Panicf("%s and %s, both spending %s", hash, *prev.vout[txin.index].spentBy, txin.prevHash)
}
prev.vout[txin.index].spentBy = &hash
}
}
}
```
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: 22bd81ac6ce3b51fc2833e4ae79ef527989428ae
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.