Robert Shearman : rpcrt4: Dereference the pointer if necessary only after doing the

Alexandre Julliard julliard at wine.codeweavers.com
Sun May 7 03:36:32 CDT 2006


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

Author: Robert Shearman <rob at codeweavers.com>
Date:   Mon May  1 10:37:11 2006 +0100

rpcrt4: Dereference the pointer if necessary only after doing the
pointer checks and writing the pointer ID to the wire.

---

 dlls/rpcrt4/ndr_marshall.c |   39 ++++++++++++++++++++++-----------------
 1 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c
index bb8156b..1448334 100644
--- a/dlls/rpcrt4/ndr_marshall.c
+++ b/dlls/rpcrt4/ndr_marshall.c
@@ -709,10 +709,6 @@ void WINAPI PointerMarshall(PMIDL_STUB_M
   pFormat += 2;
   if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
   else desc = pFormat + *(const SHORT*)pFormat;
-  if (attr & RPC_FC_P_DEREF) {
-    Pointer = *(unsigned char**)Pointer;
-    TRACE("deref => %p\n", Pointer);
-  }
 
   switch (type) {
   case RPC_FC_RP: /* ref pointer (always non-null) */
@@ -736,6 +732,10 @@ #endif
   TRACE("calling marshaller for type 0x%x\n", (int)*desc);
 
   if (Pointer) {
+    if (attr & RPC_FC_P_DEREF) {
+      Pointer = *(unsigned char**)Pointer;
+      TRACE("deref => %p\n", Pointer);
+    }
     m = NdrMarshaller[*desc & NDR_TABLE_MASK];
     if (m) m(pStubMsg, Pointer, desc);
     else FIXME("no marshaller for data type=%02x\n", *desc);
@@ -763,10 +763,6 @@ void WINAPI PointerUnmarshall(PMIDL_STUB
   pFormat += 2;
   if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
   else desc = pFormat + *(const SHORT*)pFormat;
-  if (attr & RPC_FC_P_DEREF) {
-    pPointer = *(unsigned char***)pPointer;
-    TRACE("deref => %p\n", pPointer);
-  }
 
   switch (type) {
   case RPC_FC_RP: /* ref pointer (always non-null) */
@@ -789,6 +785,12 @@ void WINAPI PointerUnmarshall(PMIDL_STUB
   }
 
   if (pointer_id) {
+    if (attr & RPC_FC_P_DEREF) {
+      if (!*pPointer || fMustAlloc)
+        *pPointer = NdrAllocate(pStubMsg, sizeof(void *));
+      pPointer = *(unsigned char***)pPointer;
+      TRACE("deref => %p\n", pPointer);
+    }
     m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
     if (m) m(pStubMsg, pPointer, desc, fMustAlloc);
     else FIXME("no unmarshaller for data type=%02x\n", *desc);
@@ -813,10 +815,6 @@ void WINAPI PointerBufferSize(PMIDL_STUB
   pFormat += 2;
   if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
   else desc = pFormat + *(const SHORT*)pFormat;
-  if (attr & RPC_FC_P_DEREF) {
-    Pointer = *(unsigned char**)Pointer;
-    TRACE("deref => %p\n", Pointer);
-  }
 
   switch (type) {
   case RPC_FC_RP: /* ref pointer (always non-null) */
@@ -834,6 +832,11 @@ void WINAPI PointerBufferSize(PMIDL_STUB
     RpcRaiseException(RPC_X_BAD_STUB_DATA);
   }
 
+  if (attr & RPC_FC_P_DEREF) {
+    Pointer = *(unsigned char**)Pointer;
+    TRACE("deref => %p\n", Pointer);
+  }
+
   m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
   if (m) m(pStubMsg, Pointer, desc);
   else FIXME("no buffersizer for data type=%02x\n", *desc);
@@ -855,9 +858,6 @@ unsigned long WINAPI PointerMemorySize(P
   pFormat += 2;
   if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
   else desc = pFormat + *(const SHORT*)pFormat;
-  if (attr & RPC_FC_P_DEREF) {
-    TRACE("deref\n");
-  }
 
   switch (type) {
   case RPC_FC_RP: /* ref pointer (always non-null) */
@@ -867,6 +867,10 @@ unsigned long WINAPI PointerMemorySize(P
     RpcRaiseException(RPC_X_BAD_STUB_DATA);
   }
 
+  if (attr & RPC_FC_P_DEREF) {
+    TRACE("deref\n");
+  }
+
   m = NdrMemorySizer[*desc & NDR_TABLE_MASK];
   if (m) m(pStubMsg, desc);
   else FIXME("no memorysizer for data type=%02x\n", *desc);
@@ -891,13 +895,14 @@ void WINAPI PointerFree(PMIDL_STUB_MESSA
   pFormat += 2;
   if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
   else desc = pFormat + *(const SHORT*)pFormat;
+
+  if (!Pointer) return;
+
   if (attr & RPC_FC_P_DEREF) {
     Pointer = *(unsigned char**)Pointer;
     TRACE("deref => %p\n", Pointer);
   }
 
-  if (!Pointer) return;
-
   m = NdrFreer[*desc & NDR_TABLE_MASK];
   if (m) m(pStubMsg, Pointer, desc);
 




More information about the wine-cvs mailing list