[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [E-devel] E CVS: libs/ecore sndev



On Sat, Jun 10, 2006 at 07:13:33PM +0200, Kim Woelders wrote:
> > --- ecore_x_icccm.c	8 Jun 2006 20:03:42 -0000	1.43
> > +++ ecore_x_icccm.c	10 Jun 2006 16:54:36 -0000	1.44
> > @@ -752,8 +752,12 @@
> >     if (argc) *argc = c;
> >     if (argv)
> >       {
> > -	(*argv) = malloc(c);
> > -	if (!*argv) return;
> > +	(*argv) = calloc(c, sizeof(char *));
> > +	if (!*argv)
> > +	  { 
> > +	     *argc = 0;
> > +	     return;
> > +	  }
> >  	for (i = 0; i < c; i++)
> >  	  (*argv)[i] = strdup(v[i]);
> >       }
> > 
> Um.. There is not much point in using calloc here since the allocated 
> area is filled entrirely with strdup pointers anyway. Not that this will 
> cause a major performance hit though :)

It does fix the bug that not enough memory was being allocated in the 
malloc(3) call.

> However, I assume you do want to fix that if calloc fails you'll get a 
> memory leak from not freeing v.

Also, it doesn't look like anything is done in case strdup(3) fails.