github-vet / github-vet/rangeloop-pointer-findings
venicegeo/pzsvc-image-catalog: catalog/harvest.go; 31 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [venicegeo/pzsvc-image-catalog](https://www.github.com/venicegeo/pzsvc-image-catalog) at [catalog/harvest.go](https://github.com/venicegeo/pzsvc-image-catalog/blob/d7fa2caddb1c5850b8b008535aa59338bf668554/catalog/harvest.go#L216-L246)
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 tgs used in defer or goroutine at line 222
[Click here to see the code in its original context.](https://github.com/venicegeo/pzsvc-image-catalog/blob/d7fa2caddb1c5850b8b008535aa59338bf668554/catalog/harvest.go#L216-L246)
Click here to show the 31 line(s) of Go which triggered the analyzer.
```go
for index, tgs := range tiles {
latIndex := int(math.Floor(float64(index) / 180.0))
lonIndex := int(math.Mod(float64(index), 180))
key := fmt.Sprintf("%03d%03d", lonIndex, latIndex)
defer func() {
if r := recover(); r != nil {
log.Printf("Recovered %v\n%v", r, tgs)
}
}()
switch len(tgs) {
case 0:
//noop
// log.Printf("Index %v was empty.", index)
case 1:
result[key] = tgs[0]
// result[key] = geos.PrepareGeometry(tgs[0])
default:
if geometry, err := geos.NewCollection(geos.GEOMETRYCOLLECTION, tgs[:]...); err == nil {
if geometry, err = geometry.Buffer(0.0); err == nil {
result[key] = geometry
// result[key] = geos.PrepareGeometry(geometry)
} else {
log.Printf("Received %v when buffering geometry for %v. Continuing.", err.Error(), index)
continue
}
} else {
log.Printf("Received %v when creating a collection for %v. Continuing", err.Error(), index)
continue
}
}
}
```
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: d7fa2caddb1c5850b8b008535aa59338bf668554
Contributor guide
No contributing guide indexed for this repository
Research direction
Read catalog/harvest.go lines 216-246 in the linked pzsvc-image-catalog commit, starting with the deferred function that references the range-loop variable tgs. Check whether the reported capture can affect the logged recovery value, then classify the finding as Bug, Mitigated, or Desirable Behavior by leaving the corresponding reaction on this issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100