[mutter/gnome-3-32] core: Check environment variables before giving to GAppLaunchContext



commit 0a3cddeecff8d2c095108fde6c8fd4a3cdc63fe0
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon May 6 13:00:09 2019 +0200

    core: Check environment variables before giving to GAppLaunchContext
    
    Depending on the type of session, one or the other might be NULL, which
    is not meant to be handled by these functions. Check for both DISPLAY
    envvars before setting them on the GAppLaunchContext.
    
    Closes: https://gitlab.gnome.org/GNOME/mutter/issues/586

 src/core/meta-launch-context.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/core/meta-launch-context.c b/src/core/meta-launch-context.c
index eda51514f..984338c1b 100644
--- a/src/core/meta-launch-context.c
+++ b/src/core/meta-launch-context.c
@@ -110,13 +110,24 @@ static void
 meta_launch_context_constructed (GObject *object)
 {
   MetaLaunchContext *context = META_LAUNCH_CONTEXT (object);
+  const char *x11_display, *wayland_display;
 
   G_OBJECT_CLASS (meta_launch_context_parent_class)->constructed (object);
 
-  g_app_launch_context_setenv (G_APP_LAUNCH_CONTEXT (context),
-                               "DISPLAY", getenv ("DISPLAY"));
-  g_app_launch_context_setenv (G_APP_LAUNCH_CONTEXT (context),
-                               "WAYLAND_DISPLAY", getenv ("WAYLAND_DISPLAY"));
+  x11_display = getenv ("DISPLAY");
+  wayland_display = getenv ("WAYLAND_DISPLAY");
+
+  if (x11_display)
+    {
+      g_app_launch_context_setenv (G_APP_LAUNCH_CONTEXT (context),
+                                   "DISPLAY", x11_display);
+    }
+
+  if (wayland_display)
+    {
+      g_app_launch_context_setenv (G_APP_LAUNCH_CONTEXT (context),
+                                   "WAYLAND_DISPLAY", wayland_display);
+    }
 }
 
 static gchar *


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