[gnome-settings-daemon/gnome-3-18] media-keys: Fix possible crash in MPRIS support



commit 72e9eedb9c4f5f64c9ae0108778507ba231392b9
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Mar 15 15:03:23 2016 +0100

    media-keys: Fix possible crash in MPRIS support
    
    If the D-Bus proxy creation was cancelled, we might have a
    use-after-free problem here.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763689

 plugins/media-keys/mpris-controller.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/plugins/media-keys/mpris-controller.c b/plugins/media-keys/mpris-controller.c
index c20d44a..71c3aa4 100644
--- a/plugins/media-keys/mpris-controller.c
+++ b/plugins/media-keys/mpris-controller.c
@@ -101,17 +101,23 @@ mpris_proxy_ready_cb (GObject      *object,
                       GAsyncResult *res,
                       gpointer      user_data)
 {
-  MprisControllerPrivate *priv = MPRIS_CONTROLLER (user_data)->priv;
+  MprisControllerPrivate *priv;
   GError *error = NULL;
+  GDBusProxy *proxy;
 
-  priv->mpris_client_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+  proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
 
-  if (!priv->mpris_client_proxy)
-    g_warning ("Error connecting to mpris interface %s", error->message);
+  if (!proxy)
+    {
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+        g_warning ("Error connecting to mpris interface %s", error->message);
+      g_clear_error (&error);
+      return;
+    }
 
+  priv = MPRIS_CONTROLLER (user_data)->priv;
+  priv->mpris_client_proxy = proxy;
   priv->connecting = FALSE;
-
-  g_clear_error (&error);
 }
 
 static void


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