rpcrt4: Fix a memory leak in union unmarshall functions by never passing fMustAlloc=TRUE into union_arm_unmarshall.

oldstable
Rob Shearman 2009-03-20 16:13:00 +00:00 committed by Alexandre Julliard
parent 1c8c45d0f6
commit ae5770d366
1 changed files with 18 additions and 3 deletions

View File

@ -5557,7 +5557,6 @@ static unsigned char *union_arm_unmarshall(PMIDL_STUB_MESSAGE pStubMsg,
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
**(void***)ppMemory = NULL;
ALIGN_POINTER(pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
if (pStubMsg->PointerBufferMark)
@ -5792,10 +5791,18 @@ unsigned char * WINAPI NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubM
if (fMustAlloc)
*ppMemory = NdrAllocate(pStubMsg, size);
/* we can't pass fMustAlloc=TRUE into the marshaller for the arm
* since the arm is part of the memory block that is encompassed by
* the whole union. Memory is forced to allocate when pointers
* are set to NULL, so we emulate that part of fMustAlloc=TRUE by
* clearing the memory we pass in to the unmarshaller */
if (fMustAlloc)
memset(*ppMemory, 0, size);
NdrBaseTypeUnmarshall(pStubMsg, ppMemory, &switch_type, FALSE);
pMemoryArm = *ppMemory + increment;
return union_arm_unmarshall(pStubMsg, &pMemoryArm, switch_value, pFormat, fMustAlloc);
return union_arm_unmarshall(pStubMsg, &pMemoryArm, switch_value, pFormat, FALSE);
}
/***********************************************************************
@ -5974,7 +5981,15 @@ unsigned char * WINAPI NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pSt
if (fMustAlloc)
*ppMemory = NdrAllocate(pStubMsg, size);
return union_arm_unmarshall(pStubMsg, ppMemory, discriminant, pFormat, fMustAlloc);
/* we can't pass fMustAlloc=TRUE into the marshaller for the arm
* since the arm is part of the memory block that is encompassed by
* the whole union. Memory is forced to allocate when pointers
* are set to NULL, so we emulate that part of fMustAlloc=TRUE by
* clearing the memory we pass in to the unmarshaller */
if (fMustAlloc)
memset(*ppMemory, 0, size);
return union_arm_unmarshall(pStubMsg, ppMemory, discriminant, pFormat, FALSE);
}
/***********************************************************************