[glib/wip/lantw/gapplication-remove-inactivity_timeout-source-on-finalize] gapplication: remove inactivity_timeout source on finalize



commit 0ed86050790036e11f0970ebb0c8b94404b32a56
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Sat Jul 27 15:28:23 2019 +0800

    gapplication: remove inactivity_timeout source on finalize
    
    The event source used to handle inactivity_timeout doesn't hold a
    reference on the application. Therefore, it is possible for callback
    function of the event source to run after the application has been
    freed, leading to use-after-free problem. To avoid the problem, we
    should remove the event source before the application is freed.
    
    This should fix SIGBUS crash of gio/tests/gapplication on FreeBSD.
    https://gitlab.gnome.org/GNOME/glib/issues/1846#note_566550

 gio/gapplication.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index 8ad4d0ff0..f702b6b9d 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -1373,6 +1373,9 @@ g_application_finalize (GObject *object)
 {
   GApplication *application = G_APPLICATION (object);
 
+  if (application->priv->inactivity_timeout_id)
+    g_source_remove (application->priv->inactivity_timeout_id);
+
   g_slist_free_full (application->priv->option_groups, (GDestroyNotify) g_option_group_unref);
   if (application->priv->main_options)
     g_option_group_unref (application->priv->main_options);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]