idle-monitor: Reset timeout before firing watch

The watch might be removed during firing, meaning the source is
destroyed after returning. Avoid use-after-free by unsetting the timeout
before firing. Returning G_SOURCE_CONTINUE in that case is harmless, as
source is destroyed.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/796

https://gitlab.gnome.org/GNOME/mutter/merge_requests/799
This commit is contained in:
Jonas Ådahl 2019-09-16 16:36:51 +02:00 committed by Georges Basile Stavracas Neto
parent 26b08d87a8
commit 0e69fe0781

View File

@ -324,9 +324,10 @@ idle_monitor_dispatch_timeout (GSource *source,
if (ready_time > now) if (ready_time > now)
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
meta_idle_monitor_watch_fire (watch);
g_source_set_ready_time (watch->timeout_source, -1); g_source_set_ready_time (watch->timeout_source, -1);
meta_idle_monitor_watch_fire (watch);
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
} }