Rob Shearman : rpcrt4: Fix NdrGetBuffer to set the correct fields in the MIDL_STUB_MESSAGE structure .

Alexandre Julliard julliard at winehq.org
Mon Dec 31 12:32:27 CST 2007


Module: wine
Branch: master
Commit: 56da854c2168c0f05630e3aaaefd863cd2d362d8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=56da854c2168c0f05630e3aaaefd863cd2d362d8

Author: Rob Shearman <rob at codeweavers.com>
Date:   Sun Dec 30 16:46:45 2007 +0000

rpcrt4: Fix NdrGetBuffer to set the correct fields in the MIDL_STUB_MESSAGE structure.

Fix NdrFreeBuffer to use the fBufferValid flag to determine whether or 
not I_RpcFreeBuffer needs to be called.

---

 dlls/rpcrt4/ndr_clientserver.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/dlls/rpcrt4/ndr_clientserver.c b/dlls/rpcrt4/ndr_clientserver.c
index a43b920..809d4cb 100644
--- a/dlls/rpcrt4/ndr_clientserver.c
+++ b/dlls/rpcrt4/ndr_clientserver.c
@@ -53,8 +53,6 @@ void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE
   TRACE("(pRpcMessage == ^%p, pStubMsg == ^%p, pStubDesc == ^%p, ProcNum == %d)\n",
     pRpcMessage, pStubMsg, pStubDesc, ProcNum);
 
-  assert( pRpcMessage && pStubMsg && pStubDesc );
-
   pRpcMessage->Handle = NULL;
   pRpcMessage->ProcNum = ProcNum;
   pRpcMessage->RpcInterfaceInformation = pStubDesc->RpcInterfaceInformation;
@@ -150,31 +148,33 @@ unsigned char* WINAPI NdrServerInitializeNew( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_M
  */
 unsigned char *WINAPI NdrGetBuffer(PMIDL_STUB_MESSAGE stubmsg, ULONG buflen, RPC_BINDING_HANDLE handle)
 {
-  TRACE("(stubmsg == ^%p, buflen == %u, handle == %p): wild guess.\n", stubmsg, buflen, handle);
-  
-  assert( stubmsg && stubmsg->RpcMsg );
+  RPC_STATUS status;
 
-  /* I guess this is our chance to put the binding handle into the RPC_MESSAGE */
-  stubmsg->RpcMsg->Handle = handle;
+  TRACE("(stubmsg == ^%p, buflen == %u, handle == %p)\n", stubmsg, buflen, handle);
   
+  stubmsg->RpcMsg->Handle = handle;
   stubmsg->RpcMsg->BufferLength = buflen;
-  if (I_RpcGetBuffer(stubmsg->RpcMsg) != S_OK)
-    return NULL;
 
-  stubmsg->Buffer = stubmsg->BufferStart = stubmsg->RpcMsg->Buffer;
+  status = I_RpcGetBuffer(stubmsg->RpcMsg);
+  if (status != RPC_S_OK)
+    RpcRaiseException(status);
+
+  stubmsg->Buffer = stubmsg->RpcMsg->Buffer;
+  stubmsg->fBufferValid = TRUE;
   stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;
-  stubmsg->BufferEnd = stubmsg->Buffer + stubmsg->BufferLength;
-  return (stubmsg->Buffer = (unsigned char *)stubmsg->RpcMsg->Buffer);
+  return stubmsg->Buffer;
 }
 /***********************************************************************
  *           NdrFreeBuffer [RPCRT4.@]
  */
 void WINAPI NdrFreeBuffer(PMIDL_STUB_MESSAGE pStubMsg)
 {
-  TRACE("(pStubMsg == ^%p): wild guess.\n", pStubMsg);
-  I_RpcFreeBuffer(pStubMsg->RpcMsg);
-  pStubMsg->BufferLength = 0;
-  pStubMsg->Buffer = pStubMsg->BufferEnd = (unsigned char *)(pStubMsg->RpcMsg->Buffer = NULL);
+  TRACE("(pStubMsg == ^%p)\n", pStubMsg);
+  if (pStubMsg->fBufferValid)
+  {
+    I_RpcFreeBuffer(pStubMsg->RpcMsg);
+    pStubMsg->fBufferValid = FALSE;
+  }
 }
 
 /************************************************************************




More information about the wine-cvs mailing list