Possible memleak?



Hi!

While tracking a memory leak in another program, I came across some
suspicious code in gtklabel.c (from 1.2.0):

static void
gtk_label_free_words (GtkLabel *label)
{
  GtkLabelWord * last;

  if (label->words)
    {
      for (last = label->words; last->next != 0; last = last->next)
        gtk_label_free_ulines (label->words);
                               ^^^^^^^^^^^^
      last->next = free_words;
      free_words = label->words;
      label->words = NULL;
    }
}

Shouldn't that be gtk_label_free_ulines (last);

>From my (limited) understanding of the code, it seems like this would
cause all rows but the first from a multi-line label to never be freed.
Is that correct?

(one-liner patch attached.)

/August.
-- 
Wrong on most accounts.  const Foo *foo; and Foo const *foo; mean the same: foo
being a pointer to const Foo.  const Foo const *foo; would mean the same but is
illegal (double const).  You are confusing this with Foo * const foo; and const
Foo * const foo; respectively. -David Kastrup, comp.os.linux.development.system
--- gtklabel.c.orig	Sun Mar  7 13:17:32 1999
+++ gtklabel.c	Sun Mar  7 13:28:15 1999
@@ -409,11 +409,11 @@
   GtkLabelWord * last;
   
   if (label->words)
     {
       for (last = label->words; last->next != 0; last = last->next)
-	gtk_label_free_ulines (label->words);
+	gtk_label_free_ulines (last);
       last->next = free_words;
       free_words = label->words;
       label->words = NULL;
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]