THRIFT-3237 Fix TNamedPipeServer::createNamedPipe memory leak
Client: cpp
Patch: Paweł Janicki & James E. King, III
This closes #632
diff --git a/lib/cpp/src/thrift/transport/TPipeServer.cpp b/lib/cpp/src/thrift/transport/TPipeServer.cpp
index baa2603..7923102 100644
--- a/lib/cpp/src/thrift/transport/TPipeServer.cpp
+++ b/lib/cpp/src/thrift/transport/TPipeServer.cpp
@@ -351,12 +351,17 @@
0, // client time-out
&sa)); // security attributes
+ DWORD lastError = GetLastError();
+ LocalFree(sd);
+ LocalFree(acl);
+ FreeSid(everyone_sid);
+
if (hPipe.h == INVALID_HANDLE_VALUE) {
Pipe_.reset();
- GlobalOutput.perror("TPipeServer::TCreateNamedPipe() GLE=", GetLastError());
+ GlobalOutput.perror("TPipeServer::TCreateNamedPipe() GLE=", lastError);
throw TTransportException(TTransportException::NOT_OPEN,
"TCreateNamedPipe() failed",
- GetLastError());
+ lastError);
return false;
}