From 2692a3754797b1261c2224c0cdb30240a13f1e78 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 6 Aug 2026 22:29:24 -0400 Subject: [PATCH] Skip interfaces that have no address getifaddrs reports an entry with a null ifa_addr for an interface that has no address assigned, such as a tunnel, so reading sa_family through it trapped while enumerating. Android already guarded for this; every platform needs it. --- Sources/Socket/System/NetworkInterface.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Sources/Socket/System/NetworkInterface.swift b/Sources/Socket/System/NetworkInterface.swift index 5c5d073..854d797 100644 --- a/Sources/Socket/System/NetworkInterface.swift +++ b/Sources/Socket/System/NetworkInterface.swift @@ -50,13 +50,10 @@ public extension NetworkInterface { assertionFailure("Unknown interface \(interfaceName)") continue } - #if os(Android) + // an interface with no address, such as a tunnel, has a null ifa_addr guard let sa_family = value.ifa_addr?.pointee.sa_family else { continue } - #else - let sa_family = value.ifa_addr.pointee.sa_family - #endif guard Address.family.rawValue == sa_family else { continue // incompatible address type }