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

dfuse-io/solana-go: cmd/slnc/cmd/get_transactions.go; 31 LoC

Open
#12,992 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [dfuse-io/solana-go](https://www.github.com/dfuse-io/solana-go) at [cmd/slnc/cmd/get_transactions.go](https://github.com/dfuse-io/solana-go/blob/cf5d0cb9653e38c5bdf3a36884db00aef8a5f8d6/cmd/slnc/cmd/get_transactions.go#L75-L105)

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 i was used in a composite literal at line 96

[Click here to see the code in its original context.](https://github.com/dfuse-io/solana-go/blob/cf5d0cb9653e38c5bdf3a36884db00aef8a5f8d6/cmd/slnc/cmd/get_transactions.go#L75-L105)

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

```go
for _, i := range ct.Transaction.Message.Instructions {

id, err := ct.Transaction.ResolveProgramIDIndex(i.ProgramIDIndex)
if err != nil {
return fmt.Errorf("unable to resolve program ID: %w", err)
}

decoder := solana.InstructionDecoderRegistry[id.String()]
if decoder == nil {
fmt.Println("raw instruction:")
fmt.Printf("Program: %s Data: %s\n", id.String(), i.Data)
fmt.Println("Accounts:")
for _, accIndex := range i.Accounts {
key := ct.Transaction.Message.AccountKeys[accIndex]

fmt.Printf("%s Is Writable: %t Is Signer: %t\n", key.String(), ct.Transaction.IsWritable(key), ct.Transaction.IsSigner(key))
}
fmt.Printf("\n\n")
continue
}

decoded, err := decoder(ct.Transaction.AccountMetaList(), &i)
if err != nil {
return fmt.Errorf("unable to decode instruction: %w", err)
}

err = text.NewEncoder(os.Stdout).Encode(decoded, nil)
if err != nil {
return fmt.Errorf("unable to text encoder instruction: %w", err)
}
}

```

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

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.