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

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