From f2b7e719543408650fef7e3290f77962654453a9 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Fri, 14 Jul 2023 10:59:05 -0400 Subject: [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 --- series/series.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'series/series.go') 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 { -- cgit v1.2.3