From 2d0091602b658e07f77d01403571c55643a1299c Mon Sep 17 00:00:00 2001 From: Lee McLaughlin Date: Tue, 25 May 2021 15:53:49 +0100 Subject: [PATCH] Fixes 4647 edge case resulting in OOB Fix 4647 bug when no matching paritiningIndex found (occurs when clicking to right of last plotted point) --- Source/Charts/Data/Implementations/Standard/ChartDataSet.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift index e9a3a9b0b3..8b006e3cf7 100644 --- a/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift @@ -199,7 +199,7 @@ open class ChartDataSet: ChartBaseDataSet let match: (ChartDataEntry) -> Bool = { $0.x >= xValue } let i = partitioningIndex(where: match) - guard self[i].x == xValue else { return [] } + guard i < endIndex && self[i].x == xValue else { return [] } return self[i...].prefix(while: { $0.x == xValue }) }