[gtk+] mir: Fix potential use of NULL GDBusConnection



commit 276c4625538b287d6aec5664f38b3df24b11b101
Author: Philip Withnall <withnall endlessm com>
Date:   Fri Nov 17 10:32:02 2017 +0000

    mir: Fix potential use of NULL GDBusConnection
    
    If we fail to connect to the session bus, it would be a bit silly to
    immediately try and use that NULL connection.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=668590

 gdk/mir/gdkmirdisplay.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c
index bedb152..1086d62 100644
--- a/gdk/mir/gdkmirdisplay.c
+++ b/gdk/mir/gdkmirdisplay.c
@@ -176,6 +176,7 @@ _gdk_mir_display_open (const gchar *display_name)
   MirPixelFormat sw_pixel_format, hw_pixel_format;
   GdkMirDisplay *display;
   GDBusConnection *session;
+  GError *error = NULL;
 
   connection = mir_connect_sync (NULL, g_get_prgname ());
   if (!connection)
@@ -208,7 +209,15 @@ _gdk_mir_display_open (const gchar *display_name)
   display->sw_pixel_format = sw_pixel_format;
   display->hw_pixel_format = hw_pixel_format;
 
-  session = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+  session = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+
+  if (session == NULL)
+    {
+      g_error ("Error connecting to D-Bus session bus: %s", error->message);
+      g_clear_error (&error);
+      mir_connection_release (connection);
+      return NULL;
+    }
 
   display->content_service = content_hub_service_proxy_new_sync (
     session,


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