Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch]: Fix memory leak of symtab.c
@ 2008-07-08  6:57 teawater
  2008-07-09 17:15 ` Joel Brobecker
  0 siblings, 1 reply; 5+ messages in thread
From: teawater @ 2008-07-08  6:57 UTC (permalink / raw)
  To: gdb-patches

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;


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

end of thread, other threads:[~2008-07-14  5:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-08  6:57 [patch]: Fix memory leak of symtab.c teawater
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

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