Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* prologue-value.c memory leak fix.
@ 2006-11-18 23:07 Pedro Alves
  2006-11-18 23:57 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: Pedro Alves @ 2006-11-18 23:07 UTC (permalink / raw)
  To: gdb-patches

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

There is a leak in prologue-value.c, in clear_values:

The do while loop always runs exactly once.
The attached patch fixes it.

/* Delete all entries from AREA.  */
static void
clear_entries (struct pv_area *area)
{
  struct area_entry *e = area->entry;

  if (e)
    {
      /* This needs to be a do-while loop, in order to actually
         process the node being checked for in the terminating
         condition.  */
      do
        {
          struct area_entry *next = e->next;
          xfree (e);
        }
      while (e != area->entry);

      area->entry = 0;
    }
}

Please review and commit.

Cheers,
Pedro Alves

---

2006-11-18 Pedro Alves <pedro_alves@portugalmail.pt>

prologue-value.c (clear_entries): Fix memory leak.



[-- Attachment #2: prologue-value.c.diff --]
[-- Type: text/plain, Size: 499 bytes --]

Index: prologue-value.c
===================================================================
RCS file: /cvs/src/src/gdb/prologue-value.c,v
retrieving revision 1.2
diff -u -p -r1.2 prologue-value.c
--- prologue-value.c	28 Mar 2006 19:19:16 -0000	1.2
+++ prologue-value.c	18 Nov 2006 23:00:35 -0000
@@ -351,6 +351,7 @@ clear_entries (struct pv_area *area)
         {
           struct area_entry *next = e->next;
           xfree (e);
+          e = next;
         }
       while (e != area->entry);
 

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

end of thread, other threads:[~2006-11-18 23:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-18 23:07 prologue-value.c memory leak fix Pedro Alves
2006-11-18 23:57 ` Daniel Jacobowitz

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