This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: fix minor memory leak in symfile.c


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)
         {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]