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.
This commit is contained in:
Andy Chun 2018-07-31 15:56:50 -07:00 committed by Geoffrey McRae
parent 0674e04597
commit f75e2fe8db

View File

@ -733,6 +733,11 @@ int run()
state.fpsSleep = 1000000 / params.fpsLimit; state.fpsSleep = 1000000 / params.fpsLimit;
char* XDG_SESSION_TYPE = getenv("XDG_SESSION_TYPE"); char* XDG_SESSION_TYPE = getenv("XDG_SESSION_TYPE");
if (XDG_SESSION_TYPE == NULL) {
XDG_SESSION_TYPE = "unspecified";
}
if (strcmp(XDG_SESSION_TYPE, "wayland") == 0) { if (strcmp(XDG_SESSION_TYPE, "wayland") == 0) {
DEBUG_INFO("Wayland detected"); DEBUG_INFO("Wayland detected");
int err = setenv("SDL_VIDEODRIVER", "wayland", 1); int err = setenv("SDL_VIDEODRIVER", "wayland", 1);