summaryrefslogtreecommitdiff
path: root/libgdm
diff options
context:
space:
mode:
authorWill Thompson <will@willthompson.co.uk>2021-11-12 14:09:07 +0000
committerWill Thompson <will@willthompson.co.uk>2021-12-21 09:45:09 +0000
commite3a6b65f768d177a822111812d5d65ce41188fe3 (patch)
tree114a8970e8a245760c786529b978efea912cc1d6 /libgdm
parent153608ab85034af6ca909fa7aa79d60e6d74d179 (diff)
downloadgdm-e3a6b65f768d177a822111812d5d65ce41188fe3.tar.gz
libgdm: Handle GDM_SUPPORTED_SESSION_TYPES being unset
If GDM_SUPPORTED_SESSION_TYPES is not set in the environment, calling any libgdm function which internally calls collect_sessions() will log a CRITICAL from trying to g_strsplit() a NULL string. This may happen if, for example, a developer is launching gnome-shell directly, rather than it being launched by GDM. Don't try to split the NULL string. The rest of collect_sessions() already gracefully handles supported_session_types being NULL, so no further changes are needed to the function. Fixes: https://gitlab.gnome.org/GNOME/gdm/-/issues/748
Diffstat (limited to 'libgdm')
-rw-r--r--libgdm/gdm-sessions.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c
index f078e04b..d8b4d5cd 100644
--- a/libgdm/gdm-sessions.c
+++ b/libgdm/gdm-sessions.c
@@ -277,9 +277,13 @@ collect_sessions (void)
DATADIR "/gdm/BuiltInSessions/",
DATADIR "/xsessions/",
};
+ const gchar *supported_session_types_env = NULL;
g_auto (GStrv) supported_session_types = NULL;
- supported_session_types = g_strsplit (g_getenv ("GDM_SUPPORTED_SESSION_TYPES"), ":", -1);
+ supported_session_types_env = g_getenv ("GDM_SUPPORTED_SESSION_TYPES");
+ if (supported_session_types_env != NULL) {
+ supported_session_types = g_strsplit (supported_session_types_env, ":", -1);
+ }
names_seen_before = g_hash_table_new (g_str_hash, g_str_equal);
xorg_search_array = g_ptr_array_new_with_free_func (g_free);