rpcrt4: Free server side arguments with MustFree flag first so other arguments may be used to determine its size.

This also fixes a leak when both MustFree and ServerAllocSize flags are
specified.
This commit is contained in:
Piotr Caban 2015-09-07 18:45:10 +02:00 committed by Alexandre Julliard
parent 98aa8528d5
commit 614afcefa3
2 changed files with 6 additions and 2 deletions

View file

@ -1161,12 +1161,14 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
if (params[i].attr.IsOut || params[i].attr.IsReturn)
call_marshaller(pStubMsg, pArg, &params[i]);
break;
case STUBLESS_FREE:
case STUBLESS_MUSTFREE:
if (params[i].attr.MustFree)
{
call_freer(pStubMsg, pArg, &params[i]);
}
else if (params[i].attr.ServerAllocSize)
break;
case STUBLESS_FREE:
if (params[i].attr.ServerAllocSize)
{
HeapFree(GetProcessHeap(), 0, *(void **)pArg);
}
@ -1455,6 +1457,7 @@ LONG WINAPI NdrStubCall2(
case STUBLESS_INITOUT:
case STUBLESS_CALCSIZE:
case STUBLESS_MARSHAL:
case STUBLESS_MUSTFREE:
case STUBLESS_FREE:
retval_ptr = stub_do_args(&stubMsg, pFormat, phase, number_of_params);
break;

View file

@ -234,6 +234,7 @@ enum stubless_phase
STUBLESS_CALCSIZE,
STUBLESS_GETBUFFER,
STUBLESS_MARSHAL,
STUBLESS_MUSTFREE,
STUBLESS_FREE
};