Commit 44649e85 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

rpcrt4: Fix NdrComplexArrayUnmarshall and NdrComplexStructUnmarshall to reuse…

rpcrt4: Fix NdrComplexArrayUnmarshall and NdrComplexStructUnmarshall to reuse memory for embedded pointers.
parent 517844e0
...@@ -2331,7 +2331,8 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -2331,7 +2331,8 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
unsigned char *pMemory, unsigned char *pMemory,
PFORMAT_STRING pFormat, PFORMAT_STRING pFormat,
PFORMAT_STRING pPointer) PFORMAT_STRING pPointer,
unsigned char fMustAlloc)
{ {
PFORMAT_STRING desc; PFORMAT_STRING desc;
NDR_UNMARSHALL m; NDR_UNMARSHALL m;
...@@ -2390,7 +2391,7 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -2390,7 +2391,7 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
else else
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */ safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
PointerUnmarshall(pStubMsg, saved_buffer, (unsigned char**)pMemory, *(unsigned char**)pMemory, pPointer, TRUE); PointerUnmarshall(pStubMsg, saved_buffer, (unsigned char**)pMemory, *(unsigned char**)pMemory, pPointer, fMustAlloc);
if (pointer_buffer_mark_set) if (pointer_buffer_mark_set)
{ {
STD_OVERFLOW_CHECK(pStubMsg); STD_OVERFLOW_CHECK(pStubMsg);
...@@ -2430,7 +2431,6 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -2430,7 +2431,6 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
size = EmbeddedComplexSize(pStubMsg, desc); size = EmbeddedComplexSize(pStubMsg, desc);
TRACE("embedded complex (size=%ld) => %p\n", size, pMemory); TRACE("embedded complex (size=%ld) => %p\n", size, pMemory);
m = NdrUnmarshaller[*desc & NDR_TABLE_MASK]; m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
memset(pMemory, 0, size); /* just in case */
if (m) if (m)
{ {
/* for some reason interface pointers aren't generated as /* for some reason interface pointers aren't generated as
...@@ -2884,10 +2884,7 @@ unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -2884,10 +2884,7 @@ unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1); ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
if (fMustAlloc || !*ppMemory) if (fMustAlloc || !*ppMemory)
{
*ppMemory = NdrAllocate(pStubMsg, size); *ppMemory = NdrAllocate(pStubMsg, size);
memset(*ppMemory, 0, size);
}
pFormat += 4; pFormat += 4;
if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat; if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
...@@ -2895,7 +2892,7 @@ unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -2895,7 +2892,7 @@ unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat; if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
pFormat += 2; pFormat += 2;
pMemory = ComplexUnmarshall(pStubMsg, *ppMemory, pFormat, pointer_desc); pMemory = ComplexUnmarshall(pStubMsg, *ppMemory, pFormat, pointer_desc, fMustAlloc);
if (conf_array) if (conf_array)
NdrConformantArrayUnmarshall(pStubMsg, &pMemory, conf_array, fMustAlloc); NdrConformantArrayUnmarshall(pStubMsg, &pMemory, conf_array, fMustAlloc);
...@@ -3470,17 +3467,14 @@ unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -3470,17 +3467,14 @@ unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount); pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
if (fMustAlloc || !*ppMemory) if (fMustAlloc || !*ppMemory)
{
*ppMemory = NdrAllocate(pStubMsg, size); *ppMemory = NdrAllocate(pStubMsg, size);
memset(*ppMemory, 0, size);
}
ALIGN_POINTER(pStubMsg->Buffer, alignment); ALIGN_POINTER(pStubMsg->Buffer, alignment);
pMemory = *ppMemory; pMemory = *ppMemory;
count = pStubMsg->ActualCount; count = pStubMsg->ActualCount;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL); pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL, fMustAlloc);
if (pointer_buffer_mark_set) if (pointer_buffer_mark_set)
{ {
......
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