[PATCH 2/6] xserver: Possible memory leaks, stricter option checks, UnInit (NewInputDeviceRequest)

Eric Anholt eric at anholt.net
Wed Mar 28 19:40:28 PDT 2007


On Wed, 2007-03-28 at 16:54 -0700, Jesse Barnes wrote:
> On Wednesday, March 28, 2007 3:05 pm Magnus Vigerlöf wrote:
> > Possible memory leaks, stricter option checks, UnInit introduction
> >
> > Added more checks on the options, specifically for the driver and
> > name/identifier options. Added unwind section to handle fault cases.
> >
> > +unwind:
> > +    if(pInfo) {
> > +        if(drv->UnInit)
> > +            drv->UnInit(drv, pInfo, 0);
> > +        else
> > +            xf86DeleteInput(pInfo, 0);
> > +    }
> > +    if(idev->driver)
> > +        xfree(idev->driver);
> > +    if(idev->identifier)
> > +        xfree(idev->identifier);
> > +    xf86optionListFree(idev->commonOptions);
> > +    xfree(idev);
> > +    return rval;
> >  }
> 
> I guess xfree can't handle freeing already NULL pointers?  If so it 
> could cleanup error paths like this a little.  Looks good though.

The first thing Xfree (what xfree() is) does is check if the pointer is
null and return if so.

-- 
Eric Anholt                             anholt at FreeBSD.org
eric at anholt.net                         eric.anholt at intel.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg/attachments/20070328/f6fb9e02/attachment.pgp>


More information about the xorg mailing list