This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] wrstabs.c (stab_start_struct_type): Close memory leak.


Michael Snyder <msnyder@vmware.com> writes:
> OK?
>
> 2011-03-08  Michael Snyder  <msnyder@vmware.com>
>
> 	* wrstabs.c (stab_start_struct_type): Close memory leak.
>
> Index: wrstabs.c
> ===================================================================
> RCS file: /cvs/src/src/binutils/wrstabs.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 wrstabs.c
> --- wrstabs.c	28 Feb 2011 18:32:51 -0000	1.20
> +++ wrstabs.c	8 Mar 2011 19:10:07 -0000
> @@ -1337,11 +1337,15 @@ stab_start_struct_type (void *p, const c
>  	   size);
>  
>    if (! stab_push_string (info, buf, tindex, definition, size))
> -    return FALSE;
> +    {
> +      free (buf);
> +      return FALSE;
> +    }
>  
>    info->type_stack->fields = (char *) xmalloc (1);
>    info->type_stack->fields[0] = '\0';
>  
> +  free (buf);
>    return TRUE;
>  }
>  

Better to replace:

  char *buf;

  buf = (char *) xmalloc (40);

with

  char buf[40];

That change is preapproved, if it works.

Richard


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]