From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: RFA: fix minor memory leak in symfile.c
Date: Sat, 13 Sep 2008 17:00:00 -0000 [thread overview]
Message-ID: <m3bpysugn4.fsf@fleche.redhat.com> (raw)
I found a small memory leak while running valgrind on gdb.
While auditing other callers of build_id_bfd_get, I found a use of
'free', so I fixed that as well. (Perhaps we ought to poison "free"?)
Built & regtested on x86-64 (compile farm).
I also verified the leak before- and after- on x86 F8.
Please review.
thanks,
Tom
:ADDPATCH symbols:
2008-09-13 Tom Tromey <tromey@redhat.com>
* symfile.c (build_id_verify): Free 'found'.
(find_separate_debug_file): Use xfree, not free.
diff --git a/gdb/symfile.c b/gdb/symfile.c
index d067d2b..ed36497 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1235,6 +1235,9 @@ build_id_verify (const char *filename, struct build_id *check)
if (!bfd_close (abfd))
warning (_("cannot close \"%s\": %s"), filename,
bfd_errmsg (bfd_get_error ()));
+
+ xfree (found);
+
return retval;
}
@@ -1363,7 +1366,7 @@ find_separate_debug_file (struct objfile *objfile)
char *build_id_name;
build_id_name = build_id_to_debug_filename (build_id);
- free (build_id);
+ xfree (build_id);
/* Prevent looping on a stripped .debug file. */
if (build_id_name != NULL && strcmp (build_id_name, objfile->name) == 0)
{
next reply other threads:[~2008-09-13 17:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-13 17:00 Tom Tromey [this message]
2008-09-13 17:08 ` Daniel Jacobowitz
2008-09-13 17:18 ` Joel Brobecker
2008-09-13 17:58 ` Tom Tromey
2008-09-13 22:35 ` Joel Brobecker
2008-09-13 22:53 ` Tom Tromey
2008-09-13 23:04 ` Joel Brobecker
2008-09-13 23:47 ` Mark Kettenis
2008-09-14 23:09 ` Thiago Jung Bauermann
2008-09-15 0:06 ` Tom Tromey
2008-09-18 1:04 ` Joel Brobecker
2008-09-18 2:31 ` 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=m3bpysugn4.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