[gnome-control-center] night-ligth-dialog: Avoid dereferencing invalid pointer



commit 1d26f63b18f54e2d354d64ec8b312c70b35a2808
Author: Andrea Azzarone <azzaronea gmail com>
Date:   Mon May 7 21:11:27 2018 +0200

    night-ligth-dialog: Avoid dereferencing invalid pointer
    
    dialog_got_proxy_cb and dialog_got_proxy_props_cb may be called after the
    instance of CcNightLightDialog has been disposed. Make sure 'self' pointer is
    not dereferenced if not valid.
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-control-center/issues/86

 panels/display/cc-night-light-dialog.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/panels/display/cc-night-light-dialog.c b/panels/display/cc-night-light-dialog.c
index 1d03ba393..b26b9e3e5 100644
--- a/panels/display/cc-night-light-dialog.c
+++ b/panels/display/cc-night-light-dialog.c
@@ -386,13 +386,18 @@ static void
 dialog_got_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
   CcNightLightDialog *self = (CcNightLightDialog *) user_data;
+  GDBusProxy *proxy;
   g_autoptr(GError) error = NULL;
-  self->proxy_color = cc_object_storage_create_dbus_proxy_finish (res, &error);
-  if (self->proxy_color == NULL)
+
+  proxy = cc_object_storage_create_dbus_proxy_finish (res, &error);
+  if (proxy == NULL)
     {
       g_warning ("failed to connect to g-s-d: %s", error->message);
       return;
     }
+
+  self->proxy_color = proxy;
+
   g_signal_connect_object (self->proxy_color, "g-properties-changed",
                            G_CALLBACK (dialog_color_properties_changed_cb), self, 0);
   dialog_update_state (self);
@@ -403,13 +408,17 @@ static void
 dialog_got_proxy_props_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
   CcNightLightDialog *self = (CcNightLightDialog *) user_data;
+  GDBusProxy *proxy;
   g_autoptr(GError) error = NULL;
-  self->proxy_color_props = cc_object_storage_create_dbus_proxy_finish (res, &error);
-  if (self->proxy_color_props == NULL)
+
+  proxy = cc_object_storage_create_dbus_proxy_finish (res, &error);
+  if (proxy == NULL)
     {
       g_warning ("failed to connect to g-s-d: %s", error->message);
       return;
     }
+
+  self->proxy_color_props = proxy;
 }
 
 static gboolean


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