From: Huw Davies Subject: Re: [PATCH 3/3] rpcrt4: Don't free server-allocated memory with the MustFree flag. Message-Id: <20181015091852.GN31910@merlot.physics.ox.ac.uk> Date: Mon, 15 Oct 2018 10:18:52 +0100 In-Reply-To: <1539470804-32048-3-git-send-email-z.figura12@gmail.com> References: <1539470804-32048-1-git-send-email-z.figura12@gmail.com> <1539470804-32048-3-git-send-email-z.figura12@gmail.com> On Sat, Oct 13, 2018 at 05:46:44PM -0500, Zebediah Figura wrote: > Since it will have already been freed in the MUSTFREE pass. > > Signed-off-by: Zebediah Figura > --- > dlls/rpcrt4/ndr_stubless.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/dlls/rpcrt4/ndr_stubless.c b/dlls/rpcrt4/ndr_stubless.c > index c2f260c..768bdc1 100644 > --- a/dlls/rpcrt4/ndr_stubless.c > +++ b/dlls/rpcrt4/ndr_stubless.c > @@ -1215,7 +1215,7 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg, > } > break; > case STUBLESS_FREE: > - if (params[i].attr.ServerAllocSize) > + if (params[i].attr.ServerAllocSize && !params[i].attr.MustFree) > { > HeapFree(GetProcessHeap(), 0, *(void **)pArg); > } Do we need to free in the IsSimpleRef case (like the else block below)? In this case the freer won't see the top-level ptr, though it may not be an issue with ServerAllocSize. Huw.