From 55ac942e7abe42d60958007b8819ebf58f72df2d Mon Sep 17 00:00:00 2001 From: Pasi4K5 Date: Mon, 14 Aug 2023 14:09:08 +0200 Subject: [PATCH] Fix `IndexOutOfRangeException` when trying to reverse a zero-length slider --- osu.Game/Rulesets/Objects/SliderPathExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Objects/SliderPathExtensions.cs b/osu.Game/Rulesets/Objects/SliderPathExtensions.cs index 2c8a6393af..1bc9668258 100644 --- a/osu.Game/Rulesets/Objects/SliderPathExtensions.cs +++ b/osu.Game/Rulesets/Objects/SliderPathExtensions.cs @@ -42,7 +42,7 @@ public static void Reverse(this SliderPath sliderPath, out Vector2 positionalOff double[] distinctSegmentEnds = segmentEnds.Distinct().ToArray(); // Remove control points at the end which do not affect the visual slider path ("invisible" control points). - if (Math.Abs(segmentEnds[^1] - segmentEnds[^2]) < 1e-10 && distinctSegmentEnds.Length > 1) + if (segmentEnds.Length >= 2 && Math.Abs(segmentEnds[^1] - segmentEnds[^2]) < 1e-10 && distinctSegmentEnds.Length > 1) { int numVisibleSegments = distinctSegmentEnds.Length - 2; var nonInheritedControlPoints = controlPoints.Where(p => p.Type is not null).ToList();