summaryrefslogtreecommitdiff
path: root/series/series.go
diff options
context:
space:
mode:
authorWill Hawkins <[email protected]>2023-07-14 10:59:05 -0400
committerWill Hawkins <[email protected]>2023-07-14 10:59:05 -0400
commitf2b7e719543408650fef7e3290f77962654453a9 (patch)
tree6b9ad557712d19a2362c0055908a8c25b58cafbe /series/series.go
parentdf37c3e0d572ff3b4b4de3e9919402e8e0ccf971 (diff)
[Bugfix]: Out of range percentile calculations
It was possible for a user of percentile-calculation functions to request a percentile that caused the underlying array of values to be accessed out of bounds. This patch fixes that error. Signed-off-by: Will Hawkins <[email protected]>
Diffstat (limited to 'series/series.go')
-rw-r--r--series/series.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/series/series.go b/series/series.go
index 43d9809..6b9af1f 100644
--- a/series/series.go
+++ b/series/series.go
@@ -127,6 +127,9 @@ func (wsi *windowSeriesWindowOnlyImpl[Data, Bucket]) previousIndex(currentIndex
func (wsi *windowSeriesWindowOnlyImpl[Data, Bucket]) toArray() []utilities.Optional[Data] {
result := make([]utilities.Optional[Data], wsi.windowSize)
+ if wsi.empty {
+ return result
+ }
iterator := wsi.latestIndex
parallelIterator := 0
for {