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

Team254/cheesy-arena: tournament/elimination_schedule.go; 44 LoC

Open
#9,963 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 [Team254/cheesy-arena](https://www.github.com/Team254/cheesy-arena) at [tournament/elimination_schedule.go](https://github.com/Team254/cheesy-arena/blob/37033f73ff9c158de59b782e9f609e9c6e42bbbc/tournament/elimination_schedule.go#L154-L197)

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 161 passes reference to match to third-party code

[Click here to see the code in its original context.](https://github.com/Team254/cheesy-arena/blob/37033f73ff9c158de59b782e9f609e9c6e42bbbc/tournament/elimination_schedule.go#L154-L197)

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

```go
for _, match := range matches {
if !match.IsComplete() {
// Update the teams in the match if they are not yet set or are incorrect.
if len(redAlliance) != 0 && !(match.Red1 == redAlliance[0].TeamId && match.Red2 == redAlliance[1].TeamId &&
match.Red3 == redAlliance[2].TeamId) {
positionRedTeams(&match, redAlliance)
match.ElimRedAlliance = redAlliance[0].AllianceId
database.SaveMatch(&match)
}
if len(blueAlliance) != 0 && !(match.Blue1 == blueAlliance[0].TeamId &&
match.Blue2 == blueAlliance[1].TeamId && match.Blue3 == blueAlliance[2].TeamId) {
positionBlueTeams(&match, blueAlliance)
match.ElimBlueAlliance = blueAlliance[0].AllianceId
database.SaveMatch(&match)
}

unplayedMatches = append(unplayedMatches, &match)
numIncomplete += 1
continue
}

// Reorder the teams based on the last complete match, so that new and unplayed matches use the same positions.
err = reorderTeams(match.Red1, match.Red2, match.Red3, redAlliance)
if err != nil {
return []model.AllianceTeam{}, err
}
err = reorderTeams(match.Blue1, match.Blue2, match.Blue3, blueAlliance)
if err != nil {
return []model.AllianceTeam{}, err
}

// Check who won.
switch match.Status {
case model.RedWonMatch:
redWins += 1
case model.BlueWonMatch:
blueWins += 1
case model.TieMatch:
ties = append(ties, &match)
default:
return []model.AllianceTeam{}, fmt.Errorf("Completed match %d has invalid winner '%s'", match.Id,
match.Status)
}
}

```

Click here to show extra information the analyzer produced.

```
No path was found through the callgraph that could lead to a function which writes a pointer argument.

The following graphviz dot graph describes paths through the callgraph that could lead to a function which passes a pointer to third-party code:
digraph G {
"(SaveMatch, 1)" -> {}
}

```

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: 37033f73ff9c158de59b782e9f609e9c6e42bbbc

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.