Blame SOURCES/idle-monitor-reset-fix.patch

657d8e
From 35333114a991440d671e3642170aa080df45a171 Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
657d8e
Date: Mon, 16 Sep 2019 16:17:48 +0200
657d8e
Subject: [PATCH 1/3] idle-monitor: Make helper function static
657d8e
657d8e
It wasn't used outside the file, so no reason to not have it static.
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/799
657d8e
---
657d8e
 src/backends/meta-idle-monitor-private.h | 1 -
657d8e
 src/backends/meta-idle-monitor.c         | 8 ++++----
657d8e
 2 files changed, 4 insertions(+), 5 deletions(-)
657d8e
657d8e
diff --git a/src/backends/meta-idle-monitor-private.h b/src/backends/meta-idle-monitor-private.h
657d8e
index 93948b14b..cc08f8c8e 100644
657d8e
--- a/src/backends/meta-idle-monitor-private.h
657d8e
+++ b/src/backends/meta-idle-monitor-private.h
657d8e
@@ -54,7 +54,6 @@ struct _MetaIdleMonitorClass
657d8e
   GObjectClass parent_class;
657d8e
 };
657d8e
 
657d8e
-void _meta_idle_monitor_watch_fire (MetaIdleMonitorWatch *watch);
657d8e
 void meta_idle_monitor_reset_idletime (MetaIdleMonitor *monitor);
657d8e
 
657d8e
 #endif /* META_IDLE_MONITOR_PRIVATE_H */
657d8e
diff --git a/src/backends/meta-idle-monitor.c b/src/backends/meta-idle-monitor.c
657d8e
index e83d6c778..de1c7e0ba 100644
657d8e
--- a/src/backends/meta-idle-monitor.c
657d8e
+++ b/src/backends/meta-idle-monitor.c
657d8e
@@ -54,8 +54,8 @@ static GParamSpec *obj_props[PROP_LAST];
657d8e
 
657d8e
 G_DEFINE_TYPE (MetaIdleMonitor, meta_idle_monitor, G_TYPE_OBJECT)
657d8e
 
657d8e
-void
657d8e
-_meta_idle_monitor_watch_fire (MetaIdleMonitorWatch *watch)
657d8e
+static void
657d8e
+meta_idle_monitor_watch_fire (MetaIdleMonitorWatch *watch)
657d8e
 {
657d8e
   MetaIdleMonitor *monitor;
657d8e
   guint id;
657d8e
@@ -324,7 +324,7 @@ idle_monitor_dispatch_timeout (GSource     *source,
657d8e
   if (ready_time > now)
657d8e
     return G_SOURCE_CONTINUE;
657d8e
 
657d8e
-  _meta_idle_monitor_watch_fire (watch);
657d8e
+  meta_idle_monitor_watch_fire (watch);
657d8e
   g_source_set_ready_time (watch->timeout_source, -1);
657d8e
 
657d8e
   return G_SOURCE_CONTINUE;
657d8e
@@ -511,7 +511,7 @@ meta_idle_monitor_reset_idletime (MetaIdleMonitor *monitor)
657d8e
 
657d8e
       if (watch->timeout_msec == 0)
657d8e
         {
657d8e
-          _meta_idle_monitor_watch_fire ((MetaIdleMonitorWatch *) watch);
657d8e
+          meta_idle_monitor_watch_fire ((MetaIdleMonitorWatch *) watch);
657d8e
         }
657d8e
       else
657d8e
         {
657d8e
-- 
657d8e
2.23.0
657d8e
657d8e
657d8e
From 07276cf94d84489d450c17b7dec5a8075c60440a Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
657d8e
Date: Mon, 16 Sep 2019 16:36:05 +0200
657d8e
Subject: [PATCH 2/3] idle-monitor: Remove redundant type cast
657d8e
657d8e
No need to type cast a `MetaIdleMonitorWatch *` to a
657d8e
`MetaIdleMonitorWatch *`.
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/799
657d8e
---
657d8e
 src/backends/meta-idle-monitor.c | 2 +-
657d8e
 1 file changed, 1 insertion(+), 1 deletion(-)
657d8e
657d8e
diff --git a/src/backends/meta-idle-monitor.c b/src/backends/meta-idle-monitor.c
657d8e
index de1c7e0ba..e5124abc1 100644
657d8e
--- a/src/backends/meta-idle-monitor.c
657d8e
+++ b/src/backends/meta-idle-monitor.c
657d8e
@@ -511,7 +511,7 @@ meta_idle_monitor_reset_idletime (MetaIdleMonitor *monitor)
657d8e
 
657d8e
       if (watch->timeout_msec == 0)
657d8e
         {
657d8e
-          meta_idle_monitor_watch_fire ((MetaIdleMonitorWatch *) watch);
657d8e
+          meta_idle_monitor_watch_fire (watch);
657d8e
         }
657d8e
       else
657d8e
         {
657d8e
-- 
657d8e
2.23.0
657d8e
657d8e
657d8e
From 73c1f387765ef528c7323e6e7ca3c05899cfcc4a Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
657d8e
Date: Mon, 16 Sep 2019 16:36:51 +0200
657d8e
Subject: [PATCH 3/3] idle-monitor: Reset timeout before firing watch
657d8e
657d8e
The watch might be removed during firing, meaning the source is
657d8e
destroyed after returning. Avoid use-after-free by unsetting the timeout
657d8e
before firing. Returning G_SOURCE_CONTINUE in that case is harmless, as
657d8e
source is destroyed.
657d8e
657d8e
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/796
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/799
657d8e
---
657d8e
 src/backends/meta-idle-monitor.c | 3 ++-
657d8e
 1 file changed, 2 insertions(+), 1 deletion(-)
657d8e
657d8e
diff --git a/src/backends/meta-idle-monitor.c b/src/backends/meta-idle-monitor.c
657d8e
index e5124abc1..9fa481742 100644
657d8e
--- a/src/backends/meta-idle-monitor.c
657d8e
+++ b/src/backends/meta-idle-monitor.c
657d8e
@@ -324,9 +324,10 @@ idle_monitor_dispatch_timeout (GSource     *source,
657d8e
   if (ready_time > now)
657d8e
     return G_SOURCE_CONTINUE;
657d8e
 
657d8e
-  meta_idle_monitor_watch_fire (watch);
657d8e
   g_source_set_ready_time (watch->timeout_source, -1);
657d8e
 
657d8e
+  meta_idle_monitor_watch_fire (watch);
657d8e
+
657d8e
   return G_SOURCE_CONTINUE;
657d8e
 }
657d8e
 
657d8e
-- 
657d8e
2.23.0
657d8e