From 273766ee6fde333a89ea1c8574272c954916a122 Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Mon, 24 Dec 2007 17:01:27 +0000 Subject: [PATCH] rpcrt4: Re-use existing memory for embedded pointers in NdrConformantVaryingArrayUnmarshall. --- 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 38210f383c0..b07f8b21840 100644 --- a/dlls/rpcrt4/ndr_marshall.c +++ b/dlls/rpcrt4/ndr_marshall.c @@ -2864,6 +2864,8 @@ unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pS ULONG bufsize, memsize; unsigned char alignment = pFormat[1] + 1; DWORD esize = *(const WORD*)(pFormat+2); + unsigned char *saved_buffer; + ULONG offset; TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc); @@ -2881,13 +2883,16 @@ unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pS bufsize = safe_multiply(esize, pStubMsg->ActualCount); memsize = safe_multiply(esize, pStubMsg->MaxCount); + offset = pStubMsg->Offset; if (!*ppMemory || fMustAlloc) *ppMemory = NdrAllocate(pStubMsg, memsize); - 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 2e392ddaffe..eee6ec22793 100644 --- a/dlls/rpcrt4/tests/server.c +++ b/dlls/rpcrt4/tests/server.c @@ -1143,7 +1143,6 @@ array_tests(void) api[0].pi = pi; get_numbers(1, 1, api); - todo_wine ok(api[0].pi == pi, "RPC conformant 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); HeapFree(GetProcessHeap(), 0, pi);