github-vet / github-vet/rangeloop-pointer-findings
vitelabs/go-vite: rpcapi/api/ledger_v2.go; 44 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [vitelabs/go-vite](https://www.github.com/vitelabs/go-vite) at [rpcapi/api/ledger_v2.go](https://github.com/vitelabs/go-vite/blob/a71ebcf1c8dc96e3b613f029a4063629c05f7c86/rpcapi/api/ledger_v2.go#L429-L472)
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 addr was used in a composite literal at line 463
[Click here to see the code in its original context.](https://github.com/vitelabs/go-vite/blob/a71ebcf1c8dc96e3b613f029a4063629c05f7c86/rpcapi/api/ledger_v2.go#L429-L472)
Click here to show the 44 line(s) of Go which triggered the analyzer.
```go
for addr, hr := range filterParam.AddrRange {
startHeight := hr.FromHeight
endHeight := hr.ToHeight
acc, err := c.GetLatestAccountBlock(addr)
if err != nil {
return nil, err
}
if acc == nil {
continue
}
if startHeight == 0 {
startHeight = 1
}
if endHeight == 0 || endHeight > acc.Height {
endHeight = acc.Height
}
for {
offset, count, finish := getHeightPage(startHeight, endHeight, 100)
if count == 0 {
break
}
startHeight = offset + 1
blocks, err := c.GetAccountBlocksByHeight(addr, offset, count)
if err != nil {
return nil, err
}
for i := len(blocks); i > 0; i-- {
if blocks[i-1].LogHash != nil {
list, err := c.GetVmLogList(blocks[i-1].LogHash)
if err != nil {
return nil, err
}
for _, l := range list {
if FilterLog(filterParam, l) {
logs = append(logs, &Logs{l, blocks[i-1].Hash, Uint64ToString(blocks[i-1].Height), &addr})
}
}
}
}
if finish {
break
}
}
}
```
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: a71ebcf1c8dc96e3b613f029a4063629c05f7c86
Contributor guide
No contributing guide indexed for this repository
Research direction
Read rpcapi/api/ledger_v2.go around lines 429-472 at commit a71ebcf1c8dc96e3b613f029a4063629c05f7c86, focusing on the reported reference to addr in the Logs literal. Check whether the behavior is a bug, mitigated, or desirable, then record the classification by leaving the corresponding reaction on this issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100