[pacman-dev] [PATCH] Fix several memleaks, mostly related to errors handling.

Xavier shiningxc at gmail.com
Mon Nov 26 18:31:53 EST 2007


On Mon, Nov 26, 2007 at 05:37:34PM -0500, Dan McGee wrote:
> > MALLOC(miss, sizeof(pmdepmissing_t), ret = -1);
> > if(ret == -1) {
> >         /* free the lists */
> >         pm_errno = blabla;
> >         goto cleanup;
> > }
> >
> > ?
> >
> > I don't know how MACRO handle arguments, so I wasn't sure this was possible.
> 
> I think it looks OK. Remember that a macro gets handled during
> preprocessing and isn't a function call at all, so you can do a few
> things you wouldn't normally be able to. Want to check? Look into
> using "gcc -E <sourcefile>", which just spits the preprocessed code
> back at you so you can check things.
> 

Ok, thanks for the tip.
Does it still look OK by using pm_errno instead of ret?

MALLOC(miss, sizeof(pmdepmissing_t), pm_errno = PM_ERR_MEMORY);
if(om_errno == PM_ERR_MEMORY) {
	/* free the lists */
	ret = -1;
	goto cleanup;
}

I'm asking because I noticed MALLOC could be used in resolvedeps too, but
there isn't already a ret variable there :)
I made this change for resolvedeps in my working branch, and for sync_prepare
in my sync branch.




More information about the pacman-dev mailing list