[PATCH 2/2] xfree86: dri2: free variable properly if code fails
Vignatti Tiago (Nokia-D/Helsinki)
tiago.vignatti at nokia.com
Wed Jun 30 06:22:10 PDT 2010
On Tue, Jun 29, 2010 at 06:55:02PM +0200, ext Michel Dänzer wrote:
> On Die, 2010-06-29 at 19:00 +0300, Tiago Vignatti wrote:
> > Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
> > ---
> > Same as the previous patch: I'm not exactly seeing any problem or segfault
> > with this code. I just got this issue with the static analyzer.
> >
> > hw/xfree86/dri2/dri2.c | 8 ++++++--
> > 1 files changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> > index d4181c9..26f5ac4 100644
> > --- a/hw/xfree86/dri2/dri2.c
> > +++ b/hw/xfree86/dri2/dri2.c
> > @@ -207,10 +207,10 @@ DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
> > return BadAlloc;
> >
> > if (!AddResource(dri2_id, dri2DrawableRes, pPriv))
> > - return BadAlloc;
> > + goto err_out;
> > if (!DRI2LookupDrawableRef(pPriv, id))
> > if (!AddResource(id, dri2DrawableRes, pPriv))
> > - return BadAlloc;
> > + goto err_out;
>
> The second error path should also free the first resource created,
> shouldn't it?
yeah, I think it makes sense.
But I don't understand how exactly the resource code works. Do you think
adding FreeResource(dri2_id, RT_NONE) is enough there?
Thanks,
Tiago
More information about the xorg-devel
mailing list