From 13e47d762aec935687d9a0c1b08e10dc37889ed9 Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Wed, 5 Dec 2007 11:56:32 +0000 Subject: [PATCH] rpcrt4: Set the memory pointer in NdrBaseTypeUnmarshall to the buffer if we're unmarshalling on a server without memory being passed in. --- dlls/rpcrt4/ndr_marshall.c | 16 ++++++++++++---- dlls/rpcrt4/tests/ndr_marshall.c | 4 ---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c index 3e5021a98e8..3f991cea949 100644 --- a/dlls/rpcrt4/ndr_marshall.c +++ b/dlls/rpcrt4/ndr_marshall.c @@ -5463,10 +5463,18 @@ static unsigned char *WINAPI NdrBaseTypeUnmarshall( #define BASE_TYPE_UNMARSHALL(type) \ ALIGN_POINTER(pStubMsg->Buffer, sizeof(type)); \ - if (fMustAlloc || !*ppMemory) \ - *ppMemory = NdrAllocate(pStubMsg, sizeof(type)); \ - TRACE("*ppMemory: %p\n", *ppMemory); \ - **(type **)ppMemory = *(type *)pStubMsg->Buffer; \ + if (!fMustAlloc && !pStubMsg->IsClient && !*ppMemory) \ + { \ + *ppMemory = pStubMsg->Buffer; \ + TRACE("*ppMemory: %p\n", *ppMemory); \ + } \ + else \ + { \ + if (fMustAlloc) \ + *ppMemory = NdrAllocate(pStubMsg, sizeof(type)); \ + TRACE("*ppMemory: %p\n", *ppMemory); \ + **(type **)ppMemory = *(type *)pStubMsg->Buffer; \ + } \ pStubMsg->Buffer += sizeof(type); switch(*pFormat) diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c index 25448e9479a..d2ea543551d 100644 --- a/dlls/rpcrt4/tests/ndr_marshall.c +++ b/dlls/rpcrt4/tests/ndr_marshall.c @@ -250,17 +250,13 @@ todo_wine { if (formattypes[2] == 0xd /* FC_ENUM16 */) ok(mem != StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem points to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart); else -todo_wine { ok(mem == StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem doesn't point to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart); - } ok(!cmp(mem, memsrc, size), "%s: incorrecly unmarshaled\n", msgpfx); ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); if (formattypes[2] != 0xd /* FC_ENUM16 */) { -todo_wine { ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); my_alloc_called = 0; - } } } HeapFree(GetProcessHeap(), 0, mem_orig);