DSU: Don't crash on bad hostname

This commit is contained in:
TellowKrinkle 2026-03-01 00:07:08 -06:00
parent 63fc9d7ca3
commit 80762e0575

View File

@ -260,11 +260,18 @@ void InputBackend::HotplugThreadFunc()
list_ports.pad_request_count = SERVER_ASKED_PADS;
list_ports.pad_ids = {0, 1, 2, 3};
msg.Finish();
if (server.m_socket.send(&list_ports, sizeof list_ports,
sf::IpAddress::resolve(server.m_address).value(),
server.m_port) != sf::Socket::Status::Done)
if (std::optional<sf::IpAddress> server_ip = sf::IpAddress::resolve(server.m_address))
{
ERROR_LOG_FMT(CONTROLLERINTERFACE, "DualShockUDPClient HotplugThreadFunc send failed");
if (server.m_socket.send(&list_ports, sizeof list_ports, *server_ip, server.m_port) !=
sf::Socket::Status::Done)
{
ERROR_LOG_FMT(CONTROLLERINTERFACE, "DualShockUDPClient HotplugThreadFunc send failed");
}
}
else
{
ERROR_LOG_FMT(CONTROLLERINTERFACE, "DualShockUDPClient failed to resolve {}",
server.m_address);
}
timed_out_servers[i] = true;
}