Skip to content

Commit

Permalink
Fix possible out of range slice access in bins history
Browse files Browse the repository at this point in the history
Make sure that the Min/Max slices are large enough by rounding up when
calculating the size of the data slices.
  • Loading branch information
janh committed Oct 10, 2023
1 parent 3a20e97 commit 1fda215
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion history/bins.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (m *snrMinMax) Reset(snr models.BinsFloat, maxBinCount, periodCount int) {
minmaxCount := m.OriginalCount
for minmaxCount > maxBinCount {
factor *= 2
minmaxCount = m.OriginalCount / factor
minmaxCount = (m.OriginalCount + factor - 1) / factor
}

minmaxGroupSize := snr.GroupSize * factor
Expand Down

0 comments on commit 1fda215

Please sign in to comment.