<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH 2 of 4] Fix various resource leaks throughout sendlib.c



Hi,

* Erik Hovland wrote:

> >> -  FREE (tcode);                /* __FREE_CHECKED__ */
> >> +  FREE (&tcode);               /* __FREE_CHECKED__ */
> >
> > The same for the use of FREE(). This is probably wrong.

> I'll have to look again. But if I recall tcode is allocated and since
> FREE takes the pointer to the pointer, the & is required. But I am not
> in front of my workstation right now. So I will defer to your
> guidance.

My fault, I didn't check it thoroughly enough. tocode is allocated as an
array and should be FREE(&tocode). Valgrind also reports a leak on fcode
so I fixed that, too plus the other leaks as b5cbd0dab863. I've
separated the fpin change to give bisect a chance in case something goes
wrong, it's pushed as 4fe35e9984ba. Thanks.

> >> -  CONTEXT f;
> >> +  CONTEXT *f = NULL;
> >
> > Here I don't understand what the leak should be. It just changes from
> > stack to allocated memory causing more overhead I think. Can you explain
> > why you change this?

> Heh, the problem here is that the function that clears CONTEXT f
> returns a pointer as an error indicator.

[...]

I see. mx_open_mailbox() allocates memory if you pass a null
pointer. Shouldn't that also be released somewhere?

Rocco