From 856bcc0a9277fc8e9f99af073e36a4d986fdec6d Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 17 Sep 2022 09:56:43 +0200 Subject: [PATCH] fix(connection): resolve() leaks memory when connection can't be made --- src/Connection.cpp | 7 +++++++ 1 file changed, 7 insertions(+), 0 deletions(-) diff --git a/src/Connection.cpp b/src/Connection.cpp index ad216b0..5285607 100644 --- a/src/Connection.cpp +++ b/src/Connection.cpp @@ -125,6 +125,13 @@ void Connection::resolve() hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_ADDRCONFIG; + // If we resolved previously, free the result. + if (this->m_host_resolved != nullptr) + { + freeaddrinfo(this->m_host_resolved); + this->m_host_resolved = nullptr; + } + // Request the OS to resolve the hostname into an IP address. // We do this even if the hostname is already an IP address, as that // makes for far easier code. -- libgit2 0.21.4