Commit 3e8a032e authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

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

parent 273766ee
...@@ -4479,6 +4479,8 @@ unsigned char * WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -4479,6 +4479,8 @@ unsigned char * WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
unsigned char alignment; unsigned char alignment;
DWORD size, elements, esize; DWORD size, elements, esize;
ULONG bufsize; ULONG bufsize;
unsigned char *saved_buffer;
ULONG offset;
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc); TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
...@@ -4517,13 +4519,16 @@ unsigned char * WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -4517,13 +4519,16 @@ unsigned char * WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
ALIGN_POINTER(pStubMsg->Buffer, alignment); ALIGN_POINTER(pStubMsg->Buffer, alignment);
bufsize = safe_multiply(esize, pStubMsg->ActualCount); bufsize = safe_multiply(esize, pStubMsg->ActualCount);
offset = pStubMsg->Offset;
if (!*ppMemory || fMustAlloc) if (!*ppMemory || fMustAlloc)
*ppMemory = NdrAllocate(pStubMsg, size); *ppMemory = NdrAllocate(pStubMsg, size);
pStubMsg->BufferMark = pStubMsg->Buffer; saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
safe_copy_from_buffer(pStubMsg, *ppMemory + pStubMsg->Offset, bufsize); 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; return NULL;
} }
......
...@@ -1137,7 +1137,6 @@ array_tests(void) ...@@ -1137,7 +1137,6 @@ array_tests(void)
*pi = -1; *pi = -1;
api[0].pi = pi; api[0].pi = pi;
get_5numbers(1, api); 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 == 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); ok(*api[0].pi == 0, "pi unmarshalled incorrectly %d\n", *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