From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: RFA: fix memory leak in dwarf2read.c
Date: Thu, 28 Aug 2008 22:14:00 -0000 [thread overview]
Message-ID: <m3iqtkwzyz.fsf@fleche.redhat.com> (raw)
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;
next reply other threads:[~2008-08-28 22:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-28 22:14 Tom Tromey [this message]
2008-08-28 22:34 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3iqtkwzyz.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox