From 5b471eb7e335815887db169536864b000154f9c8 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Wed, 27 Dec 2023 16:36:52 -0500 Subject: [PATCH] ply-device-manager: Handle XKB failing to load more gracefully Right now we always assume `xkb_context_new` will succeed. This isn't necessarily true. If it fails, we shouldn't crash. This commit fixes that. --- src/libply-splash-core/ply-device-manager.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c index bfdd28d7..59e579dd 100644 --- a/src/libply-splash-core/ply-device-manager.c +++ b/src/libply-splash-core/ply-device-manager.c @@ -849,7 +849,7 @@ parse_vconsole_conf (ply_device_manager_t *manager) ply_trace ("KEYMAP: %s, XKBLAYOUT: %s, XKBMODEL %s, XKBVARIANT: %s, XKBOPTIONS: %s\n", keymap, xkb_layout, xkb_model, xkb_variant, xkb_options); - if (xkb_layout != NULL) { + if (xkb_layout != NULL && manager->xkb_context != NULL) { struct xkb_rule_names xkb_keymap = { .layout = xkb_layout, .model = xkb_model, @@ -879,6 +879,10 @@ ply_device_manager_new (const char *default_tty, manager = calloc (1, sizeof(ply_device_manager_t)); manager->loop = NULL; manager->xkb_context = xkb_context_new (XKB_CONTEXT_NO_FLAGS); + + if (manager->xkb_context == NULL) + ply_trace ("Could not allocate xkb context: %m"); + parse_vconsole_conf (manager); manager->terminals = ply_hashtable_new (ply_hashtable_string_hash, ply_hashtable_string_compare);