* RFA: fix memory leak in dwarf2read.c
@ 2008-08-28 22:14 Tom Tromey
2008-08-28 22:34 ` Daniel Jacobowitz
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2008-08-28 22:14 UTC (permalink / raw)
To: gdb-patches
I found a memory leak while looking at dwarf2read.
We xstrdup the directory name, but nothing ever frees it.
The simplest fix seemed to be to allocate it on the objfile obstack.
Built and regtested on x86-64 (compile farm).
I also verified this, before and after, with valgrind.
Ok?
Tom
:ADDPATCH dwarf:
2008-08-28 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (dwarf2_build_psymtabs_hard): Copy dirname on
obstack.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 5cb444e..95a85b1 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1529,7 +1529,9 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
objfile->static_psymbols.next);
if (comp_unit_die.dirname)
- pst->dirname = xstrdup (comp_unit_die.dirname);
+ pst->dirname = obsavestring (comp_unit_die.dirname,
+ strlen (comp_unit_die.dirname),
+ &objfile->objfile_obstack);
pst->read_symtab_private = (char *) this_cu;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: RFA: fix memory leak in dwarf2read.c
2008-08-28 22:14 RFA: fix memory leak in dwarf2read.c Tom Tromey
@ 2008-08-28 22:34 ` Daniel Jacobowitz
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2008-08-28 22:34 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Thu, Aug 28, 2008 at 04:12:52PM -0600, Tom Tromey wrote:
> :ADDPATCH dwarf:
>
> 2008-08-28 Tom Tromey <tromey@redhat.com>
>
> * dwarf2read.c (dwarf2_build_psymtabs_hard): Copy dirname on
> obstack.
:REVIEWMAIL:
OK, thanks.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-08-28 22:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-28 22:14 RFA: fix memory leak in dwarf2read.c Tom Tromey
2008-08-28 22:34 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox