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

butchland/BuildItBreakItFixItForSparta: other_teams/51/code/src/bibifi/logappend/logappend.go; 20 LoC

Open
#11,691 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 [butchland/BuildItBreakItFixItForSparta](https://www.github.com/butchland/BuildItBreakItFixItForSparta) at [other_teams/51/code/src/bibifi/logappend/logappend.go](https://github.com/butchland/BuildItBreakItFixItForSparta/blob/ee32f74a8754b979fe51b2720c667712cc7c2fb7/other_teams/51/code/src/bibifi/logappend/logappend.go#L46-L65)

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 cmd is reassigned at line 53

[Click here to see the code in its original context.](https://github.com/butchland/BuildItBreakItFixItForSparta/blob/ee32f74a8754b979fe51b2720c667712cc7c2fb7/other_teams/51/code/src/bibifi/logappend/logappend.go#L46-L65)

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

```go
for _, cmd := range cmds {
log, ok := logs[cmd.Log]
if ok {
continue
}
var lazy *cmdline.AppendCmd
if !batch {
lazy = &cmd
}
log, err = logfile.Load(cmd.Log, cmd.Token, cachef, lazy)
if err != nil {
dbg("main load: " + err.Error())
fmt.Fprintln(os.Stderr, "security error")
if !batch {
os.Exit(-1)
}
}
logs[cmd.Log] = log
keys[cmd.Log] = cmd.Token
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Open other_teams/51/code/src/bibifi/logappend/logappend.go and inspect lines 46-65, especially the range over cmds and the reference passed to logfile.Load. Decide whether the analyzer finding is a bug, mitigated, or desirable behavior, then record that classification using the requested reaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.