Rob Shearman : rpcrt4: Re-use existing memory for embedded pointers in NdrVaryingArrayUnmarshall.

Alexandre Julliard julliard at winehq.org
Wed Dec 26 10:05:08 CST 2007


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

Author: Rob Shearman <rob at codeweavers.com>
Date:   Mon Dec 24 17:01:40 2007 +0000

rpcrt4: Re-use existing memory for embedded pointers in NdrVaryingArrayUnmarshall.

---

 dlls/rpcrt4/ndr_marshall.c |   11 ++++++++---
 dlls/rpcrt4/tests/server.c |    1 -
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c
index b07f8b2..60e057f 100644
--- a/dlls/rpcrt4/ndr_marshall.c
+++ b/dlls/rpcrt4/ndr_marshall.c
@@ -4479,6 +4479,8 @@ unsigned char *  WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
     unsigned char alignment;
     DWORD size, elements, esize;
     ULONG bufsize;
+    unsigned char *saved_buffer;
+    ULONG offset;
 
     TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
 
@@ -4517,13 +4519,16 @@ unsigned char *  WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
     ALIGN_POINTER(pStubMsg->Buffer, alignment);
 
     bufsize = safe_multiply(esize, pStubMsg->ActualCount);
+    offset = pStubMsg->Offset;
 
     if (!*ppMemory || fMustAlloc)
         *ppMemory = NdrAllocate(pStubMsg, size);
-    pStubMsg->BufferMark = pStubMsg->Buffer;
-    safe_copy_from_buffer(pStubMsg, *ppMemory + pStubMsg->Offset, bufsize);
+    saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
+    safe_buffer_increment(pStubMsg, bufsize);
 
-    EmbeddedPointerUnmarshall(pStubMsg, *ppMemory, *ppMemory, pFormat, TRUE /* FIXME */);
+    EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
+
+    memcpy(*ppMemory + offset, saved_buffer, bufsize);
 
     return NULL;
 }
diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c
index eee6ec2..425b20b 100644
--- a/dlls/rpcrt4/tests/server.c
+++ b/dlls/rpcrt4/tests/server.c
@@ -1137,7 +1137,6 @@ array_tests(void)
   *pi = -1;
   api[0].pi = pi;
   get_5numbers(1, api);
-  todo_wine
   ok(api[0].pi == pi, "RPC varying array [out] pointer changed from %p to %p\n", pi, api[0].pi);
   ok(*api[0].pi == 0, "pi unmarshalled incorrectly %d\n", *pi);
 




More information about the wine-cvs mailing list