From: Mark Slee Date: Mon, 9 Jul 2007 19:50:30 +0000 (+0000) Subject: Fix addrinfo structure memory leak in TSocket X-Git-Tag: 0.2.0~1315 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=85287d3989359231026807bac52364cbe49b8d84;p=common%2Fthrift.git Fix addrinfo structure memory leak in TSocket Summary: Need to free the IPv6 memory structure Reviewed By: mcslee Notes: Submitted by paul@powerset.com git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665157 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/cpp/src/concurrency/Mutex.h b/lib/cpp/src/concurrency/Mutex.h index d4788b38..7945e057 100644 --- a/lib/cpp/src/concurrency/Mutex.h +++ b/lib/cpp/src/concurrency/Mutex.h @@ -48,7 +48,7 @@ private: impl* impl_; }; -class Guard{ +class Guard { public: Guard(const Mutex& value) : mutex_(value) { mutex_.lock(); diff --git a/lib/cpp/src/transport/TSocket.cpp b/lib/cpp/src/transport/TSocket.cpp index bfd3387a..a5a07b37 100644 --- a/lib/cpp/src/transport/TSocket.cpp +++ b/lib/cpp/src/transport/TSocket.cpp @@ -249,10 +249,14 @@ void TSocket::open() { close(); } else { close(); + freeaddrinfo(res0); // cleanup on failure throw; } } } + + // Free address structure memory + freeaddrinfo(res0); } void TSocket::close() {