From: Michael Snyder <msnyder@vmware.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFA] elfread.c (elf_symtab_read): Stop memory leak.
Date: Mon, 07 Mar 2011 19:51:00 -0000 [thread overview]
Message-ID: <4D7535D1.8030601@vmware.com> (raw)
In-Reply-To: <20110307111540.GB30306@adacore.com>
Joel Brobecker wrote:
>> 2011-03-05 Michael Snyder <msnyder@vmware.com>
>>
>> * elfread.c (elf_symtab_read): Stop memory leak.
>
> I think that's OK. A little more nervous than usual, as I had
> to look through a fair bit of code. But you did run this change
> past the testsuite, right?
Not one by one, but I batch them up, yes.
> Note that we could possibly be using alloca to avoid the use
> of heap allocation. However, as I have learnt the hard way
> in the past, it's a really bad idea to do so in a loop (one
> can exhaust the stack very effectively that way).
Thanks, committed.
>
>> 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
>
>
next prev parent reply other threads:[~2011-03-07 19:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-05 20:35 Michael Snyder
2011-03-07 11:20 ` Joel Brobecker
2011-03-07 19:51 ` Michael Snyder [this message]
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=4D7535D1.8030601@vmware.com \
--to=msnyder@vmware.com \
--cc=brobecker@adacore.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