[gdm/wjt/handle-missing-GDM_SUPPORTED_SESSION_TYPES-env: 3/3] libgdm: Handle GDM_SUPPORTED_SESSION_TYPES being unset




commit e3a6b65f768d177a822111812d5d65ce41188fe3
Author: Will Thompson <will willthompson co uk>
Date:   Fri Nov 12 14:09:07 2021 +0000

    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(-)
---
diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c
index f078e04b8..d8b4d5cdb 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);


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