Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] elfread.c (elf_symtab_read): Stop memory leak.
@ 2011-03-05 20:35 Michael Snyder
  2011-03-07 11:20 ` Joel Brobecker
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Snyder @ 2011-03-05 20:35 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 5 bytes --]

OK?


[-- Attachment #2: elfread.txt --]
[-- Type: text/plain, Size: 1123 bytes --]

2011-03-05  Michael Snyder  <msnyder@vmware.com>

	* elfread.c (elf_symtab_read): Stop memory leak.

Index: elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.103
diff -u -p -r1.103 elfread.c
--- elfread.c	7 Jan 2011 19:36:16 -0000	1.103
+++ elfread.c	5 Mar 2011 20:33:20 -0000
@@ -242,6 +242,7 @@ elf_symtab_read (struct objfile *objfile
   char *filesymname = "";
   struct dbx_symfile_info *dbx = objfile->deprecated_sym_stab_info;
   int stripped = (bfd_get_symcount (objfile->obfd) == 0);
+  struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
 
   for (i = 0; i < number_of_symbols; i++)
     {
@@ -464,6 +465,7 @@ elf_symtab_read (struct objfile *objfile
 				     * max_index));
 			  sectinfo = (struct stab_section_info *)
 			    xmalloc (size);
+			  make_cleanup (xfree, sectinfo);
 			  memset (sectinfo, 0, size);
 			  sectinfo->num_sections = max_index;
 			  if (filesym == NULL)
@@ -572,6 +574,7 @@ elf_symtab_read (struct objfile *objfile
 	    }
 	}
     }
+  do_cleanups (back_to);
 }
 
 struct build_id

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-05-03 16:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-05 20:35 [RFA] elfread.c (elf_symtab_read): Stop memory leak Michael Snyder
2011-03-07 11:20 ` Joel Brobecker
2011-03-07 19:51   ` Michael Snyder
2011-05-03 15:54   ` Joel Brobecker
2011-05-03 16:28     ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox