From f75e2fe8dbeff26a08c18f18061abda17b2b31a6 Mon Sep 17 00:00:00 2001 From: Andy Chun Date: Tue, 31 Jul 2018 15:56:50 -0700 Subject: [PATCH] Default XDG_SESSION_TYPE to `unspecified` Minimal systems in cases may not have XDG_SESSION_TYPE set at all, causing the program to segfault at the `strcmp`. This commit sets XDG_SESSION_TYPE to `unspecified` (according to https://www.freedesktop.org/software/systemd/man/pam_systemd.html) if it is not defined in the environment. --- client/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/main.c b/client/main.c index b8337867..eb4a4455 100644 --- a/client/main.c +++ b/client/main.c @@ -733,6 +733,11 @@ int run() state.fpsSleep = 1000000 / params.fpsLimit; char* XDG_SESSION_TYPE = getenv("XDG_SESSION_TYPE"); + + if (XDG_SESSION_TYPE == NULL) { + XDG_SESSION_TYPE = "unspecified"; + } + if (strcmp(XDG_SESSION_TYPE, "wayland") == 0) { DEBUG_INFO("Wayland detected"); int err = setenv("SDL_VIDEODRIVER", "wayland", 1);