Skip to content

Commit cf5fa83

Browse files
authored
Correctly handle the error of the getaddrinfo function (#191)
1 parent 4b66320 commit cf5fa83

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

trantor/net/inner/NormalResolver.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ void NormalResolver::resolve(const std::string &hostname,
5656
}
5757
}
5858
}
59-
struct addrinfo hints, *res;
59+
struct addrinfo hints, *res = nullptr;
6060
memset(&hints, 0, sizeof(hints));
6161
hints.ai_family = PF_UNSPEC;
6262
hints.ai_socktype = SOCK_STREAM;
6363
hints.ai_flags = AI_PASSIVE;
6464
auto error = getaddrinfo(hostname.data(), nullptr, &hints, &res);
65-
if (error == -1 || res == nullptr)
65+
if (error != 0 || res == nullptr)
6666
{
6767
LOG_SYSERR << "InetAddress::resolve";
6868
if (res != nullptr)

0 commit comments

Comments
 (0)