summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2013-03-23 22:55:40 -0700
committerPhilip Langdale <philipl@overt.org>2013-03-30 16:26:05 -0700
commit4094fb8e4793981e0f516569a1b5d4a2144f0ab7 (patch)
treed247a205eb24719f1a1ccd7e52c477819035471f
parentd31ebff2b2d9a44f380ada8887c77dfdee770eb5 (diff)
downloadgvfs-4094fb8e4793981e0f516569a1b5d4a2144f0ab7.tar.gz
Daemon: Ensure monitors are not prematurally finalized.
If a monitor is being cleaned up due to the backend disappearing, we could see the monitor being finalized as a result of removing a subscriber, leading to a segfault as it continues to access its internal state. https://bugzilla.gnome.org/show_bug.cgi?id=696479
-rw-r--r--daemon/gvfsmonitor.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/daemon/gvfsmonitor.c b/daemon/gvfsmonitor.c
index 12ec6b99..cdf0dc2a 100644
--- a/daemon/gvfsmonitor.c
+++ b/daemon/gvfsmonitor.c
@@ -71,7 +71,14 @@ backend_died (GVfsMonitor *monitor,
GObject *old_backend)
{
Subscriber *subscriber;
-
+
+ /*
+ * Take an extra ref on the monitor because
+ * unsubscribing may lead to the last ref
+ * being released.
+ */
+ g_object_ref (G_OBJECT (monitor));
+
monitor->priv->backend = NULL;
while (monitor->priv->subscribers != NULL)
@@ -79,6 +86,8 @@ backend_died (GVfsMonitor *monitor,
subscriber = monitor->priv->subscribers->data;
unsubscribe (subscriber);
}
+
+ g_object_unref (G_OBJECT (monitor));
}
static void