From 8290d01644044272a8db6e54bc1b55ed15d58564 Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Fri, 27 Apr 2018 13:25:32 +0800 Subject: [PATCH] Fix memory leak in DNSResolve --- gsock.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gsock.cpp b/gsock.cpp index 8835a18..03a343c 100644 --- a/gsock.cpp +++ b/gsock.cpp @@ -469,11 +469,13 @@ int DNSResolve(const std::string& HostName, std::string& _out_IPStr) case AF_INET: sockaddr_in * addr = (struct sockaddr_in*) (ptr->ai_addr); _out_IPStr = inet_ntoa(addr->sin_addr); + freeaddrinfo(result); return 0; break; } } /// Unknown error. + freeaddrinfo(result); return -2; }