[PATCH 4/6] xserver: Memory leak fixes (configAddDevice)

Magnus Vigerlöf Magnus.Vigerlof at home.se
Thu Mar 29 16:17:07 PDT 2007


On Thursday 29 March 2007 02:00, Jesse Barnes wrote:
> On Wednesday, March 28, 2007 3:09 pm Magnus Vigerlöf wrote:
> > diff --git a/config/config.c b/config/config.c
> > index 02c2f23..4462da6 100644
> > --- a/config/config.c
> > +++ b/config/config.c
> > @@ -110,6 +110,11 @@ configAddDevice(DBusMessage *message, DB
> >
> >      options->key = xstrdup("_source");
> >      options->value = xstrdup("client/dbus");
> > +    if(!options->key || !options->value) {
> > +        ErrorF("[config] couldn't allocate first key/value pair\n");
> > +        ret = BadAlloc;
> > +        goto unwind;
> > +    }
>
> Is the ErrorF really necessary here?  Shouldn't the caller be notifying
> the user of problems rather than internal library code like this?  I
> guess it's all over in this code though, so... looks good.

When in Rome...

I was initially confused about the numerous methods to allocate memory (six 
different #defines and wrapper function sets to the standard malloc et al 
that does the same thing (yes, I've counted them...)), and this is no better 
I guess...

However, I'd rather do this in a separate patch once an agreed set of 
debug/output macros/functions are defined.

Thanks for checking the patch!
 Magnus V



More information about the xorg mailing list