Fix DNSLookup memory leak (#422)

* Fix memory leak with shared_ptr and -fsanitize=address

* Replace addrinfo* by shared_ptr

* fsanitize=address only on Linux

* Add USE_WS Linux CI test

* Remove fsanitize from the cmake files

* Remove USE_WS in linux test suite
This commit is contained in:
itytophile
2022-12-23 02:13:51 +01:00
committed by GitHub
parent a5d4911a16
commit 679ce519dd
5 changed files with 24 additions and 35 deletions

View File

@ -102,7 +102,7 @@ namespace ix
// First do DNS resolution
//
auto dnsLookup = std::make_shared<DNSLookup>(hostname, port);
struct addrinfo* res = dnsLookup->resolve(errMsg, isCancellationRequested);
auto res = dnsLookup->resolve(errMsg, isCancellationRequested);
if (res == nullptr)
{
return -1;
@ -112,7 +112,7 @@ namespace ix
// iterate through the records to find a working peer
struct addrinfo* address;
for (address = res; address != nullptr; address = address->ai_next)
for (address = res.get(); address != nullptr; address = address->ai_next)
{
//
// Second try to connect to the remote host
@ -124,7 +124,6 @@ namespace ix
}
}
freeaddrinfo(res);
return sockfd;
}