diff --git a/ixwebsocket/IXDNSLookup.cpp b/ixwebsocket/IXDNSLookup.cpp index 09618704..938d75e3 100644 --- a/ixwebsocket/IXDNSLookup.cpp +++ b/ixwebsocket/IXDNSLookup.cpp @@ -68,6 +68,11 @@ namespace ix : resolveUnCancellable(errMsg, isCancellationRequested); } + void DNSLookup::release(struct addrinfo* addr) + { + freeaddrinfo(addr); + } + struct addrinfo* DNSLookup::resolveUnCancellable( std::string& errMsg, const CancellationRequest& isCancellationRequested) { diff --git a/ixwebsocket/IXDNSLookup.h b/ixwebsocket/IXDNSLookup.h index 754da263..fcdd103d 100644 --- a/ixwebsocket/IXDNSLookup.h +++ b/ixwebsocket/IXDNSLookup.h @@ -31,6 +31,8 @@ namespace ix const CancellationRequest& isCancellationRequested, bool cancellable = true); + void release(struct addrinfo* addr); + private: struct addrinfo* resolveCancellable(std::string& errMsg, const CancellationRequest& isCancellationRequested); diff --git a/test/IXDNSLookupTest.cpp b/test/IXDNSLookupTest.cpp index 31a7e0aa..ca1180ee 100644 --- a/test/IXDNSLookupTest.cpp +++ b/test/IXDNSLookupTest.cpp @@ -24,6 +24,8 @@ TEST_CASE("dns", "[net]") res = dnsLookup->resolve(errMsg, [] { return false; }); std::cerr << "Error message: " << errMsg << std::endl; REQUIRE(res != nullptr); + + dnsLookup->release(res); } SECTION("Test resolving a non-existing hostname")