Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@vmware.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [RFA] elfread.c (elf_symtab_read): Stop memory leak.
Date: Sat, 05 Mar 2011 20:35:00 -0000	[thread overview]
Message-ID: <4D729E84.3050401@vmware.com> (raw)

[-- 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

             reply	other threads:[~2011-03-05 20:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-05 20:35 Michael Snyder [this message]
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

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=4D729E84.3050401@vmware.com \
    --to=msnyder@vmware.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