From dc0a85d34f52d084eb31931c4287f0b3abda54a7 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 3 Nov 2025 22:06:55 +0800 Subject: [PATCH] fix: net: use an exception in NetworkAddress::resolve() Instead of asserting that the number of resolved ipv4 addresses is nonzero, throw an exception. This will prevent the core from aborting if the host has no ipv4 addresses. The host can get into this state if the remote device loses its ipv4 advertisement midway through resolving, such as if an mdns host unpublishes its ipv4 address as a result of going into a low-power state. Signed-off-by: Sean Cross --- src/lib/net/NetworkAddress.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/net/NetworkAddress.cpp b/src/lib/net/NetworkAddress.cpp index e7bfc8fae..f2dd621fd 100644 --- a/src/lib/net/NetworkAddress.cpp +++ b/src/lib/net/NetworkAddress.cpp @@ -142,7 +142,9 @@ size_t NetworkAddress::resolve(size_t index) } resolvedAddressesCount = ipv4OnlyAddresses.size(); - assert(resolvedAddressesCount > 0); + if (resolvedAddressesCount <= 0) { + throw ArchNetworkNameUnknownException("Hostname lookup failed"); + } if (index < resolvedAddressesCount - 1) { m_address = ipv4OnlyAddresses[index]; } else {