From e584ee011bac06e2f3bc34809214e2b983caa642 Mon Sep 17 00:00:00 2001 From: Artur Bulakaiev Date: Tue, 17 Dec 2019 16:52:02 +0200 Subject: [PATCH] Fixed "Index out of range" bug in control channel, that causes network extension to be unloaded Now we iterate over reversed array and removing elements from it is safe --- TunnelKit/Sources/Protocols/OpenVPN/ControlChannel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TunnelKit/Sources/Protocols/OpenVPN/ControlChannel.swift b/TunnelKit/Sources/Protocols/OpenVPN/ControlChannel.swift index 5b544d0c..7be6e59f 100644 --- a/TunnelKit/Sources/Protocols/OpenVPN/ControlChannel.swift +++ b/TunnelKit/Sources/Protocols/OpenVPN/ControlChannel.swift @@ -199,7 +199,7 @@ extension OpenVPN { } // drop queued out packets if ack-ed - for (i, packet) in queue.outbound.enumerated() { + for (i, packet) in queue.outbound.enumerated().reversed() { if packetIds.contains(packet.packetId) { queue.outbound.remove(at: i) }