From e29e5bd6508eadce4c0f1901dd25dd048e521fc5 Mon Sep 17 00:00:00 2001 From: TrueZhuanjia Date: Fri, 9 Jan 2026 10:48:24 +0800 Subject: [PATCH] fixed: app crash caused by detecting hosts with alternative IPs --- VoidLink/Network/DiscoveryWorker.m | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/VoidLink/Network/DiscoveryWorker.m b/VoidLink/Network/DiscoveryWorker.m index 8e578817..8a8c315f 100644 --- a/VoidLink/Network/DiscoveryWorker.m +++ b/VoidLink/Network/DiscoveryWorker.m @@ -46,16 +46,17 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds if (_host.localAddress != nil) { [array addObject:_host.localAddress]; } - if(_host.activeAddressPool.count>0){ - for(NSString* address in _host.activeAddressPool){ - if([address containsString:@":"]) break; - [array addObject:address]; - } - for(NSString* address in _host.activeAddressPool){ - if(![address containsString:@":"]) break; - [array addObject:address]; - } + + NSArray *poolSnapshot = [_host.activeAddressPool copy]; + for (NSString *address in poolSnapshot) { + if ([address containsString:@":"]) break; + [array addObject:address]; } + for (NSString *address in poolSnapshot) { + if (![address containsString:@":"]) break; + [array addObject:address]; + } + if (_host.address != nil) { [array addObject:_host.address]; }