mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 12:49:45 +00:00
rpcrt4: Fix a memory leak in union unmarshall functions by never passing fMustAlloc=TRUE into union_arm_unmarshall.
This commit is contained in:
parent
1c8c45d0f6
commit
ae5770d366
@ -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);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user