From 1e01a55cdcb9b57bfd041806ceb925309f6cdeb9 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 22 Feb 2014 20:16:28 +0100 Subject: [PATCH] core: prevent early MetaIdleMonitor destruction when its invoker vanishes If the last reference of a MetaIdleMonitor is held by the caller, it may happen that the last reference is lost when calling the GDestroyNotify, if this happens when the watched DBus name vanishes, the object (and the watches hashtable) are destroyed while manipulating the watches hashtable, so bad things may happen then. Fix this by wrapping the operation by a ref/unref pair, so the object would be destroyed after operating on the hashtable. https://bugzilla.gnome.org/show_bug.cgi?id=724969 --- src/core/meta-idle-monitor.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/meta-idle-monitor.c b/src/core/meta-idle-monitor.c index eda92893f..edc3c61ab 100644 --- a/src/core/meta-idle-monitor.c +++ b/src/core/meta-idle-monitor.c @@ -605,8 +605,10 @@ meta_idle_monitor_remove_watch (MetaIdleMonitor *monitor, { g_return_if_fail (META_IS_IDLE_MONITOR (monitor)); + g_object_ref (monitor); g_hash_table_remove (monitor->watches, GUINT_TO_POINTER (id)); + g_object_unref (monitor); } /**