This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [RFA] wrstabs.c (stab_start_struct_type): Close memory leak.
- From: Richard Sandiford <richard dot sandiford at linaro dot org>
- To: Michael Snyder <msnyder at vmware dot com>
- Cc: "binutils\ at sourceware dot org" <binutils at sourceware dot org>
- Date: Mon, 14 Mar 2011 12:26:49 +0000
- Subject: Re: [RFA] wrstabs.c (stab_start_struct_type): Close memory leak.
- References: <4D76800E.2040107@vmware.com>
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