From e3a6b65f768d177a822111812d5d65ce41188fe3 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 12 Nov 2021 14:09:07 +0000 Subject: 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 --- libgdm/gdm-sessions.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libgdm') 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); -- cgit v1.2.1