* [RFA] wrstabs.c (stab_start_struct_type): Close memory leak.
@ 2011-03-08 19:14 Michael Snyder
2011-03-14 12:27 ` Richard Sandiford
0 siblings, 1 reply; 2+ messages in thread
From: Michael Snyder @ 2011-03-08 19:14 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 5 bytes --]
OK?
[-- Attachment #2: wrstabs.txt --]
[-- Type: text/plain, Size: 725 bytes --]
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;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFA] wrstabs.c (stab_start_struct_type): Close memory leak.
2011-03-08 19:14 [RFA] wrstabs.c (stab_start_struct_type): Close memory leak Michael Snyder
@ 2011-03-14 12:27 ` Richard Sandiford
0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2011-03-14 12:27 UTC (permalink / raw)
To: Michael Snyder; +Cc: binutils
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-14 12:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-08 19:14 [RFA] wrstabs.c (stab_start_struct_type): Close memory leak Michael Snyder
2011-03-14 12:27 ` Richard Sandiford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).