aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-12-18 15:11:05 +0100
committeremersion <contact@emersion.fr>2017-12-18 15:11:05 +0100
commit2c31cac11623207a02c33734bc77d4ee3b286e8a (patch)
tree3f06fa91050727c2173ca3a07fe944b7609b00d9 /rootston
parentf3769a4b1f552b7dc826418e78b88bffe277c2c4 (diff)
downloadwlroots-2c31cac11623207a02c33734bc77d4ee3b286e8a.tar.xz
Do not segfault when loading an unknown keymap
Diffstat (limited to 'rootston')
-rw-r--r--rootston/keyboard.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/rootston/keyboard.c b/rootston/keyboard.c
index 4aaf2d48..758a49fb 100644
--- a/rootston/keyboard.c
+++ b/rootston/keyboard.c
@@ -354,8 +354,16 @@ struct roots_keyboard *roots_keyboard_create(struct wlr_input_device *device,
wlr_log(L_ERROR, "Cannot create XKB context");
return NULL;
}
- wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context,
- &rules, XKB_KEYMAP_COMPILE_NO_FLAGS));
+
+ struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules,
+ XKB_KEYMAP_COMPILE_NO_FLAGS);
+ if (keymap == NULL) {
+ xkb_context_unref(context);
+ wlr_log(L_ERROR, "Cannot create XKB keymap");
+ return NULL;
+ }
+
+ wlr_keyboard_set_keymap(device->keyboard, keymap);
xkb_context_unref(context);
int repeat_rate = (config->repeat_rate > 0) ? config->repeat_rate : 25;