From: teawater <teawater@gmail.com>
To: gdb-patches@sourceware.org
Subject: [patch]: Fix memory leak of symtab.c
Date: Tue, 08 Jul 2008 06:57:00 -0000 [thread overview]
Message-ID: <daef60380807072356s1072dae5t6d3d24c8b4ef3674@mail.gmail.com> (raw)
symtab.c has a memory leek in function expand_line_sal. struct block
**blocks and int *filter are xmalloc at line 4459 and 4460. There are
returns at the end of this function without calling xfree. And these
variables is just used in this function. So I change them to "alloca".
This patch is for the GDB cvs version.
2008-06-21 Hui Zhu <teawater@gmail.com>
* symtab.c (expand_line_sal): Fix a memory leak.
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4456,8 +4456,8 @@ expand_line_sal (struct symtab_and_line
blocks -- for each PC found above we see if there are other PCs
that are in the same block. If yes, the other PCs are filtered out. */
- filter = xmalloc (ret.nelts * sizeof (int));
- blocks = xmalloc (ret.nelts * sizeof (struct block *));
+ filter = alloca (ret.nelts * sizeof (int));
+ blocks = alloca (ret.nelts * sizeof (struct block *));
for (i = 0; i < ret.nelts; ++i)
{
filter[i] = 1;
next reply other threads:[~2008-07-08 6:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-08 6:57 teawater [this message]
2008-07-09 17:15 ` Joel Brobecker
2008-07-10 3:07 ` teawater
2008-07-13 17:03 ` Joel Brobecker
2008-07-14 5:58 ` teawater
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=daef60380807072356s1072dae5t6d3d24c8b4ef3674@mail.gmail.com \
--to=teawater@gmail.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