Robert Shearman : rpcrt4: Fix some memory leaks.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Apr 20 08:45:57 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: b36d5fa11fd6e4a155ba5023a633e2c05585c316
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=b36d5fa11fd6e4a155ba5023a633e2c05585c316

Author: Robert Shearman <rob at codeweavers.com>
Date:   Thu Apr 20 11:44:53 2006 +0100

rpcrt4: Fix some memory leaks.

---

 dlls/rpcrt4/rpc_binding.c |    5 +++++
 dlls/rpcrt4/rpc_server.c  |   10 ++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/dlls/rpcrt4/rpc_binding.c b/dlls/rpcrt4/rpc_binding.c
index 63f0259..9b3e705 100644
--- a/dlls/rpcrt4/rpc_binding.c
+++ b/dlls/rpcrt4/rpc_binding.c
@@ -446,6 +446,7 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding
                                  InterfaceId, TransferSyntax);
 
     status = RPCRT4_Send(*Connection, hdr, NULL, 0);
+    RPCRT4_FreeHeader(hdr);
     if (status != RPC_S_OK) {
       RPCRT4_DestroyConnection(*Connection);
       return status;
@@ -461,6 +462,7 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding
     count = rpcrt4_conn_read(NewConnection, response, RPC_MAX_PACKET_SIZE);
     if (count < sizeof(response_hdr->common)) {
       WARN("received invalid header\n");
+      HeapFree(GetProcessHeap(), 0, response);
       RPCRT4_DestroyConnection(*Connection);
       return RPC_S_PROTOCOL_ERROR;
     }
@@ -471,12 +473,14 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding
         response_hdr->common.rpc_ver_minor != RPC_VER_MINOR ||
         response_hdr->common.ptype != PKT_BIND_ACK) {
       WARN("invalid protocol version or rejection packet\n");
+      HeapFree(GetProcessHeap(), 0, response);
       RPCRT4_DestroyConnection(*Connection);
       return RPC_S_PROTOCOL_ERROR;
     }
 
     if (response_hdr->bind_ack.max_tsize < RPC_MIN_PACKET_SIZE) {
       WARN("server doesn't allow large enough packets\n");
+      HeapFree(GetProcessHeap(), 0, response);
       RPCRT4_DestroyConnection(*Connection);
       return RPC_S_PROTOCOL_ERROR;
     }
@@ -485,6 +489,7 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding
 
     (*Connection)->MaxTransmissionSize = response_hdr->bind_ack.max_tsize;
     (*Connection)->ActiveInterface = *InterfaceId;
+    HeapFree(GetProcessHeap(), 0, response);
   }
 
   return RPC_S_OK;
diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c
index d8eaa6b..96b3a44 100644
--- a/dlls/rpcrt4/rpc_server.c
+++ b/dlls/rpcrt4/rpc_server.c
@@ -261,7 +261,9 @@ static void RPCRT4_process_packet(RpcCon
         conn->MaxTransmissionSize = hdr->bind.max_tsize;
       }
 
-      if (RPCRT4_Send(conn, response, NULL, 0) != RPC_S_OK)
+      status = RPCRT4_Send(conn, response, NULL, 0);
+      RPCRT4_FreeHeader(response);
+      if (status != RPC_S_OK)
         goto fail;
 
       break;
@@ -275,6 +277,7 @@ static void RPCRT4_process_packet(RpcCon
                                            status);
 
         RPCRT4_Send(conn, response, NULL, 0);
+        RPCRT4_FreeHeader(response);
         break;
       }
 
@@ -342,6 +345,7 @@ fail:
   msg->Buffer = NULL;
   RPCRT4_FreeHeader(hdr);
   TlsSetValue(worker_tls, NULL);
+  HeapFree(GetProcessHeap(), 0, msg);
 }
 
 static DWORD CALLBACK RPCRT4_worker_thread(LPVOID the_arg)
@@ -414,6 +418,7 @@ static DWORD CALLBACK RPCRT4_io_thread(L
     status = RPCRT4_Receive(conn, &hdr, msg);
     if (status != RPC_S_OK) {
       WARN("receive failed with error %lx\n", status);
+      HeapFree(GetProcessHeap(), 0, msg);
       break;
     }
 
@@ -430,7 +435,6 @@ #else
 #endif
     msg = NULL;
   }
-  HeapFree(GetProcessHeap(), 0, msg);
   RPCRT4_DestroyConnection(conn);
   return 0;
 }
@@ -1001,6 +1005,8 @@ RPC_STATUS WINAPI RpcMgmtWaitServerListe
   
   LeaveCriticalSection(&listen_cs);
 
+  FIXME("not waiting for server calls to finish\n");
+
   return RPC_S_OK;
 }
 




More information about the wine-cvs mailing list