github-vet / github-vet/rangeloop-pointer-findings
snowzach/mjpeg: mjproxy/proxy.go; 45 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [snowzach/mjpeg](https://www.github.com/snowzach/mjpeg) at [mjproxy/proxy.go](https://github.com/snowzach/mjpeg/blob/0d1fb95974e2c6975048b9b8c8242c2c31fed322/mjproxy/proxy.go#L42-L86)
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.
> range-loop variable streamConfig used in defer or goroutine at line 49
[Click here to see the code in its original context.](https://github.com/snowzach/mjpeg/blob/0d1fb95974e2c6975048b9b8c8242c2c31fed322/mjproxy/proxy.go#L42-L86)
Click here to show the 45 line(s) of Go which triggered the analyzer.
```go
for _, streamConfig := range streams {
stream := mjpeg.NewStream(50 * time.Millisecond)
go func() {
// Open capture
capture, err := gocv.OpenVideoCapture(streamConfig.Url)
if err != nil {
fmt.Printf("Error opening capture url: %v: %v\n", streamConfig.Url, err)
return
}
defer capture.Close()
// create the mjpeg stream
img := gocv.NewMat()
defer img.Close()
for {
// Read an image
if ok := capture.Read(&img); !ok {
return
}
if img.Empty() {
continue
}
// re-encode with boxes
data, err := gocv.IMEncode(".jpg", img)
if err != nil {
continue
}
stream.UpdateJPEG(data)
}
}()
if username := config.GetString("server.username"); username != "" {
http.HandleFunc("/"+streamConfig.Name, BasicAuth(stream.ServeHTTP, username, config.GetString("server.password")))
} else {
http.Handle("/"+streamConfig.Name, stream)
}
log.Printf("Added stream '/%s' from %s\n", streamConfig.Name, streamConfig.Url)
}
```
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: 0d1fb95974e2c6975048b9b8c8242c2c31fed322
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.