From 7bdf5d41897db88a889f6706f26d66b4da172c84 Mon Sep 17 00:00:00 2001 From: Jeroen Hofstee Date: Tue, 22 Sep 2020 21:43:55 +0200 Subject: [PATCH] config: check the return value of xkb_context_new When xkb_context_new returns NULL and that is passed on to xkb_keymap_new_from_names, sway will crash. This happens for example if xkeyboard-config is not installed. Exit with an error message instead. --- sway/config.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sway/config.c b/sway/config.c index 71382b864..75bce77f1 100644 --- a/sway/config.c +++ b/sway/config.c @@ -38,6 +38,9 @@ struct sway_config *config = NULL; static struct xkb_state *keysym_translation_state_create( struct xkb_rule_names rules) { struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + if (!context) + sway_abort("Failed to create XKB context"); + struct xkb_keymap *xkb_keymap = xkb_keymap_new_from_names( context, &rules,