[PATCH 1/2] xfree86: fix a memory leak in edidMakeAtom().

Michel Dänzer michel at daenzer.net
Wed Jul 31 08:22:02 PDT 2013


On Son, 2013-07-28 at 18:05 +0200, Julien Cristau wrote:
> On Thu, Jul 11, 2013 at 18:27:14 -0400, Alex Deucher wrote:
> > On Thu, Jul 11, 2013 at 6:02 PM, Julien Cristau <jcristau at debian.org> wrote:
> > > On Mon, Jun 17, 2013 at 12:39:20 -0400, alexdeucher at gmail.com wrote:
> > >
> > >> From: Leo Liu <leo.liu at amd.com>
> > >>
> > >> leak happens when looping xrandr prop.
> > >>
> > >> Signed-off-by: Leo Liu <leo.liu at amd.com>
> > >> ---
> > >>  hw/xfree86/common/xf86Helper.c |    1 +
> > >>  1 file changed, 1 insertion(+)
> > >>
> > >> diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
> > >> index 721159d..bb17ecc 100644
> > >> --- a/hw/xfree86/common/xf86Helper.c
> > >> +++ b/hw/xfree86/common/xf86Helper.c
> > >> @@ -1813,6 +1813,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
> > >>      }
> > >>      else {
> > >>          free(pNewProp->name);
> > >> +        free(pNewProp->data);
> > >>          existing = TRUE;
> > >>      }
> > >>
> > > AFAICT xf86RegisterRootWindowProperty can be called with non-malloc
> > > 'value' (e.g. for the SeatId stuff in InitOutput, although that's only
> > > for serverGeneration == 1).  Is there any way to make this a little more
> > > obviously correct?
> > 
> > How about:
> > 
> >       else {
> >           free(pNewProp->name);
> > +        if(pNewProp->data)
> > +            free(pNewProp->data);
> >           existing = TRUE;
> > 
> That doesn't really change anything.  I was thinking more of making sure
> that function is always called with malloced data.

Leo implemented the attached two approaches which hopefully address your
concern. Which of these would be preferable, or did you think of yet
another approach?


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: approach1-0001-xfree86-fix-a-memory-leak-in-edidMakeAtom.patch
Type: text/x-patch
Size: 2456 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20130731/81135917/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: approach2-0001-xfree86-fix-a-memory-leak-in-edidMakeAtom.patch
Type: text/x-patch
Size: 1999 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20130731/81135917/attachment-0003.bin>


More information about the xorg-devel mailing list