github-vet / github-vet/rangeloop-pointer-findings
ctc-oss/xviewgo: detect.go; 39 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [ctc-oss/xviewgo](https://www.github.com/ctc-oss/xviewgo) at [detect.go](https://github.com/ctc-oss/xviewgo/blob/9c8f10d6b78dec1a0a5b32dbc499d1243c19c178/detect.go#L108-L146)
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 chip was used in a composite literal at line 142
[Click here to see the code in its original context.](https://github.com/ctc-oss/xviewgo/blob/9c8f10d6b78dec1a0a5b32dbc499d1243c19c178/detect.go#L108-L146)
Click here to show the 39 line(s) of Go which triggered the analyzer.
```go
for _, chip := range chips {
buf := bytes.Buffer{}
jpeg.Encode(&buf, chip.Im, nil)
tensor, err := loadImageTensor(buf.Bytes())
if err != nil {
log.Fatal(err)
}
output, err := session.Run(
map[tf.Output]*tf.Tensor{
graph.Operation("image_tensor").Output(0): tensor,
},
[]tf.Output{
graph.Operation("detection_boxes").Output(0),
graph.Operation("detection_scores").Output(0),
graph.Operation("detection_classes").Output(0),
graph.Operation("num_detections").Output(0),
},
nil)
if err != nil {
log.Fatal(err)
}
boxes := output[0].Value().([][][]float32)[0]
scores := output[1].Value().([][]float32)[0]
classes := output[2].Value().([][]float32)[0]
for i, score := range scores {
class := classes[i]
bounds := transformBox(chip.X, chip.Y, boxes[i])
detects = append(detects,
Detect{
Bounds: ResizeRect(bounds, ratio),
Class: CID(class),
Chip: &chip,
Confidence: score,
})
}
}
```
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: 9c8f10d6b78dec1a0a5b32dbc499d1243c19c178
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.