This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

prologue-value.c memory leak fix.


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.


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);
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]