From 2281a6f432cfa17585e95b212878b65fb48c7e7c Mon Sep 17 00:00:00 2001 From: DavidKmn Date: Mon, 23 May 2022 17:45:35 +0100 Subject: [PATCH] Add index validity check on goBack method --- Sources/FlowStacks/RoutableCollection+utilities.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/FlowStacks/RoutableCollection+utilities.swift b/Sources/FlowStacks/RoutableCollection+utilities.swift index 82e8f82..d3a33df 100644 --- a/Sources/FlowStacks/RoutableCollection+utilities.swift +++ b/Sources/FlowStacks/RoutableCollection+utilities.swift @@ -62,6 +62,7 @@ public extension RoutableCollection where Element: RouteProtocol { /// Goes back a given number of screens off the stack /// - Parameter count: The number of screens to go back. Defaults to 1. mutating func goBack(_ count: Int = 1) { + guard self.count - count >= 0 else { return } removeLast(count) }