Mike McCormack : rpcrt4: Fix a possible memory leak, cleanup a bit.

Alexandre Julliard julliard at wine.codeweavers.com
Thu May 18 09:44:17 CDT 2006


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

Author: Mike McCormack <mike at codeweavers.com>
Date:   Thu May 18 19:07:38 2006 +0900

rpcrt4: Fix a possible memory leak, cleanup a bit.

---

 dlls/rpcrt4/rpc_binding.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/dlls/rpcrt4/rpc_binding.c b/dlls/rpcrt4/rpc_binding.c
index 8e2c4bb..c3aebbd 100644
--- a/dlls/rpcrt4/rpc_binding.c
+++ b/dlls/rpcrt4/rpc_binding.c
@@ -261,14 +261,15 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding
   RPCRT4_CreateConnection(&NewConnection, Binding->server, Binding->Protseq,
                           Binding->NetworkAddr, Binding->Endpoint, NULL,
                           Binding->AuthInfo, Binding);
-  *Connection = NewConnection;
   status = RPCRT4_OpenConnection(NewConnection);
-  if (status != RPC_S_OK) {
+  if (status != RPC_S_OK)
+  {
+    RPCRT4_DestroyConnection(NewConnection);
     return status;
   }
-
+ 
   /* we need to send a binding packet if we are client. */
-  if (!(*Connection)->server) {
+  if (!NewConnection->server) {
     RpcPktHdr *hdr;
     RpcPktHdr *response_hdr;
     RPC_MESSAGE msg;
@@ -279,17 +280,17 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding
                                  RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE,
                                  InterfaceId, TransferSyntax);
 
-    status = RPCRT4_Send(*Connection, hdr, NULL, 0);
+    status = RPCRT4_Send(NewConnection, hdr, NULL, 0);
     RPCRT4_FreeHeader(hdr);
     if (status != RPC_S_OK) {
-      RPCRT4_DestroyConnection(*Connection);
+      RPCRT4_DestroyConnection(NewConnection);
       return status;
     }
 
     status = RPCRT4_Receive(NewConnection, &response_hdr, &msg);
     if (status != RPC_S_OK) {
       ERR("receive failed\n");
-      RPCRT4_DestroyConnection(*Connection);
+      RPCRT4_DestroyConnection(NewConnection);
       return status;
     }
 
@@ -297,17 +298,19 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding
         response_hdr->bind_ack.max_tsize < RPC_MIN_PACKET_SIZE) {
       ERR("failed to bind\n");
       RPCRT4_FreeHeader(response_hdr);
-      RPCRT4_DestroyConnection(*Connection);
+      RPCRT4_DestroyConnection(NewConnection);
       return RPC_S_PROTOCOL_ERROR;
     }
 
     /* FIXME: do more checks? */
 
-    (*Connection)->MaxTransmissionSize = response_hdr->bind_ack.max_tsize;
-    (*Connection)->ActiveInterface = *InterfaceId;
+    NewConnection->MaxTransmissionSize = response_hdr->bind_ack.max_tsize;
+    NewConnection->ActiveInterface = *InterfaceId;
     RPCRT4_FreeHeader(response_hdr);
   }
-  Binding->FromConn = *Connection;
+
+  Binding->FromConn = NewConnection;
+  *Connection = NewConnection;
 
   return RPC_S_OK;
 }




More information about the wine-cvs mailing list