From 6790d1ec5c8868b8faffaafbcb5cbc25a64648a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Fri, 17 Nov 2017 18:31:28 +0100 Subject: [PATCH] SockAddr: set service to null if string is empty --- src/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.cpp b/src/utils.cpp index 9cd9f492..850f3768 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -38,7 +38,7 @@ SockAddr::resolve(const std::string& host, const std::string& service) memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_DGRAM; addrinfo* info = nullptr; - int rc = getaddrinfo(host.c_str(), service.c_str(), &hints, &info); + int rc = getaddrinfo(host.c_str(), service.empty() ? nullptr : service.c_str(), &hints, &info); if(rc != 0) throw std::invalid_argument(std::string("Error: `") + host + ":" + service + "`: " + gai_strerror(rc)); -- GitLab