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 d4788b3..7945e05 100644
--- a/lib/cpp/src/concurrency/Mutex.h
+++ b/lib/cpp/src/concurrency/Mutex.h
@@ -48,7 +48,7 @@
   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 bfd3387..a5a07b3 100644
--- a/lib/cpp/src/transport/TSocket.cpp
+++ b/lib/cpp/src/transport/TSocket.cpp
@@ -249,10 +249,14 @@
         close();
       } else {
         close();
+        freeaddrinfo(res0); // cleanup on failure
         throw;
       }
     }
   }
+
+  // Free address structure memory
+  freeaddrinfo(res0);
 }
 
 void TSocket::close() {