]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Tunnel edit: Fix crash
authorRoopesh Chander <roop@roopc.net>
Mon, 24 Dec 2018 07:28:35 +0000 (12:58 +0530)
committerRoopesh Chander <roop@roopc.net>
Mon, 24 Dec 2018 07:31:21 +0000 (13:01 +0530)
This fixes a crash that happens when you:

1. Scroll to the end of the Edit screen
2. Delete a peer
3. Toggle the Activate On Demand switch

Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift

index 6fc0646c019f2f510cf628fdce9e5a7d9c715284..a8d504e549fe6961cbdb945352b0200eee93fc4e 100644 (file)
@@ -417,7 +417,8 @@ extension TunnelEditTableViewController {
                 self.activateOnDemandSetting.isActivateOnDemandEnabled = isOn
                 self.loadSections()
 
-                let indexPaths = (1 ..< 4).map { IndexPath(row: $0, section: indexPath.section) }
+                let section = self.sections.firstIndex(where: { $0 == .onDemand })!
+                let indexPaths = (1 ..< 4).map { IndexPath(row: $0, section: section) }
                 if isOn {
                     if self.activateOnDemandSetting.activateOnDemandOption == .none {
                         self.activateOnDemandSetting.activateOnDemandOption = TunnelViewModel.defaultActivateOnDemandOption()