Bug in gtk_box_remove.



Hi all,

Here's a patch for gtkbox.c. In gtk_box_remove, the removed widget is referred 
to after it's been unparent'ed. However, it may not exist anymore then. (In 
fact, in my program it didn't. However, the bug did not cause a crash until I 
started using ccmalloc, which (among many other useful things) fills free'd 
memory with fencepost values, so that dereferencing pointers in it causes a 
crash.)

--- gtk+-0.99.8.old/gtk/gtkbox.c	Thu Feb 19 08:18:39 1998
+++ gtk+-0.99.8/gtk/gtkbox.c	Fri Mar 20 10:42:19 1998
@@ -566,7 +566,8 @@
 	  g_list_free (children);
 	  g_free (child);
 
-	  if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (container))
+	  /* Shouldn't check widget here; it may not exist anymore. */
+	  if (GTK_WIDGET_VISIBLE (container))
 	    gtk_widget_queue_resize (GTK_WIDGET (container));
 
 	  break;

Regards,

Johannes.

P.S. I'll also upload things to the ftp site.
--
"No one is quite as blind as a victim of the game" - Garth Brooks

Self-professed nerd of Mathematics and Computer Science.




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