Take a reference on the gio file monitors while signaling pending file changes
authorRobert Bragg <robert@linux.intel.com>
Wed, 6 May 2009 08:20:43 +0000 (09:20 +0100)
committerAlexander Larsson <alexl@redhat.com>
Wed, 20 May 2009 12:23:53 +0000 (14:23 +0200)
It was possible for a signal handler to remove the last reference and
dispose the monitor.  If there were remaining pending_file_changes they
tried to dereference the disposed monitor.

This patch simply calls g_object_{ref,unref} around the loop that signals
the changes.

gio/gfilemonitor.c

index 108e7a6c45ea9fb0ec6129f1576c16124565ede0..41444e360c67bda2e77b4685db405098fbd466ca 100644 (file)
@@ -364,6 +364,7 @@ emit_cb (gpointer data)
   monitor->priv->pending_file_changes = NULL;
   monitor->priv->pending_file_change_id = 0;
 
+  g_object_ref (monitor);
   for (iter = pending; iter; iter = iter->next)
     {
        FileChange *change = iter->data;
@@ -372,6 +373,8 @@ emit_cb (gpointer data)
        file_change_free (change);
     }
   g_slist_free (pending);
+  g_object_unref (monitor);
+
   return FALSE;
 }