From 276c4625538b287d6aec5664f38b3df24b11b101 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 17 Nov 2017 10:32:02 +0000 Subject: [PATCH] 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 https://bugzilla.gnome.org/show_bug.cgi?id=668590 --- gdk/mir/gdkmirdisplay.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c index bedb1524a9..1086d62173 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,