github-vet / github-vet/rangeloop-pointer-findings

MatrixAINetwork/go-matrix: blkverify/block_verify.go; 8 LoC

Open
#9,882 0 comments 0 reactions 0 assignees View on GitHub
fresh tiny
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [MatrixAINetwork/go-matrix](https://www.github.com/MatrixAINetwork/go-matrix) at [blkverify/block_verify.go](https://github.com/MatrixAINetwork/go-matrix/blob/aed2396f13b5801b5f36c892077ee73ab4354e16/blkverify/block_verify.go#L279-L286)

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.

> function call at line 285 may store a reference to block

[Click here to see the code in its original context.](https://github.com/MatrixAINetwork/go-matrix/blob/aed2396f13b5801b5f36c892077ee73ab4354e16/blkverify/block_verify.go#L279-L286)

Click here to show the 8 line(s) of Go which triggered the analyzer.

```go
for _, block := range blocks {
if block.req.Header.Number.Uint64() <= curNumber {
log.Info(self.logExtraInfo(), "reloadVerifiedBlocks", "req 高度 <= 当前高度, 不处理", "block number", block.req.Header.Number.Uint64(), "cur number", curNumber)
continue
}
log.Info(self.logExtraInfo(), "reloadVerifiedBlocks", "缓存 verified block", "block number", block.req.Header.Number.Uint64(), "hash", block.hash.TerminalString())
self.processManage.AddVerifiedBlock(&block)
}

```

Click here to show extra information the analyzer produced.

```
The following graphviz dot graph describes paths through the callgraph that could lead to a function which writes a pointer argument:
digraph G {
"(AddVerifiedBlock, 1)" -> {}
}

No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.

```

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: aed2396f13b5801b5f36c892077ee73ab4354e16

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.