* [RFA] dwarf.c (display_debug_frames): Free allocated memory.
@ 2011-03-08 21:41 Michael Snyder
2011-03-25 17:33 ` Nick Clifton
0 siblings, 1 reply; 2+ messages in thread
From: Michael Snyder @ 2011-03-08 21:41 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 5 bytes --]
OK?
[-- Attachment #2: dwarf.txt --]
[-- Type: text/plain, Size: 1243 bytes --]
2011-03-08 Michael Snyder <msnyder@vmware.com>
* dwarf.c (display_debug_frames): Free allocated memory.
Index: dwarf.c
===================================================================
RCS file: /cvs/src/src/binutils/dwarf.c,v
retrieving revision 1.84
diff -u -p -r1.84 dwarf.c
--- dwarf.c 23 Feb 2011 08:52:33 -0000 1.84
+++ dwarf.c 8 Mar 2011 21:39:52 -0000
@@ -4127,6 +4127,7 @@ display_debug_frames (struct dwarf_secti
int max_regs = 0;
const char *bad_reg = _("bad register: ");
int saved_eh_addr_size = eh_addr_size;
+ Frame_Chunk *fc = NULL;
printf (_("Contents of the %s section:\n"), section->name);
@@ -4136,7 +4137,6 @@ display_debug_frames (struct dwarf_secti
unsigned char *block_end;
unsigned long length;
unsigned long cie_id;
- Frame_Chunk *fc;
Frame_Chunk *cie;
int need_col_headers = 1;
unsigned char *augmentation_data = NULL;
@@ -4181,6 +4181,7 @@ display_debug_frames (struct dwarf_secti
{
int version;
+ free (fc);
fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk));
memset (fc, 0, sizeof (Frame_Chunk));
@@ -4913,7 +4914,7 @@ display_debug_frames (struct dwarf_secti
}
printf ("\n");
-
+ free (fc);
return 1;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFA] dwarf.c (display_debug_frames): Free allocated memory.
2011-03-08 21:41 [RFA] dwarf.c (display_debug_frames): Free allocated memory Michael Snyder
@ 2011-03-25 17:33 ` Nick Clifton
0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2011-03-25 17:33 UTC (permalink / raw)
To: Michael Snyder; +Cc: binutils
Hi Michael,
> 2011-03-08 Michael Snyder<msnyder@vmware.com>
>
> * dwarf.c (display_debug_frames): Free allocated memory.
Sorry - this one is wrong:
> + free (fc);
> fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk));
The chunk you are freeing here may be the statically allocated fde_fc
chunk. Plus these chunks are put on a chain which is walked by code
later on in the function.
To free the memory you will have to wait to the end of the function and
then walk the chain, freeing chunks as you go and watching out for the
static chunk. (Or else arrange for that chunk to be allocated as well).
Cheers
Nick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-25 17:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-08 21:41 [RFA] dwarf.c (display_debug_frames): Free allocated memory Michael Snyder
2011-03-25 17:33 ` Nick Clifton
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).