GSourceCallback leak in gmain.c



The GSourceCallback allocated in g_source_set_callback is leaked. The
ref_count is also not initialized, so the notify call can be called at the
wrong time (or not at all).

Here is a patch, can I check it in?

Index: gmain.c
===================================================================
RCS file: /cvs/gnome/glib/gmain.c,v
retrieving revision 1.52
diff -u -p -r1.52 gmain.c
--- gmain.c	2001/01/03 20:18:40	1.52
+++ gmain.c	2001/01/22 12:31:08
@@ -984,6 +984,7 @@ g_source_callback_unref (gpointer cb_dat
     {
       if (callback->notify)
 	callback->notify (callback->data);
+      g_free (callback);
     }
 }
 
@@ -1024,7 +1025,8 @@ g_source_set_callback (GSource        *s
   g_return_if_fail (source != NULL);
 
   new_callback = g_new (GSourceCallback, 1);
-  
+
+  new_callback->ref_count = 1;
   new_callback->func = func;
   new_callback->data = data;
   new_callback->notify = notify;

/ Alex






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