Fix addrinfo structure memory leak in TSocket
authorMark Slee <mcslee@apache.org>
Mon, 9 Jul 2007 19:50:30 +0000 (19:50 +0000)
committerMark Slee <mcslee@apache.org>
Mon, 9 Jul 2007 19:50:30 +0000 (19:50 +0000)
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

lib/cpp/src/concurrency/Mutex.h
lib/cpp/src/transport/TSocket.cpp

index d4788b3..7945e05 100644 (file)
@@ -48,7 +48,7 @@ private:
   impl* impl_;
 };
 
-class Guard{
+class Guard {
  public: 
   Guard(const Mutex& value) : mutex_(value) {
     mutex_.lock();
index bfd3387..a5a07b3 100644 (file)
@@ -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() {