Commit 273766ee authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

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

parent a05923e1
......@@ -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;
}
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment