From 7105864e13c7a83f57d22edce619fe511a9d1342 Mon Sep 17 00:00:00 2001 From: random human Date: Sun, 2 Sep 2018 21:16:24 +0530 Subject: Handle setting keymap in examples more securely --- examples/rotation.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'examples/rotation.c') diff --git a/examples/rotation.c b/examples/rotation.c index add7f42f..7cf5727b 100644 --- a/examples/rotation.c +++ b/examples/rotation.c @@ -188,8 +188,14 @@ void new_input_notify(struct wl_listener *listener, void *data) { wlr_log(WLR_ERROR, "Failed to create XKB context"); exit(1); } - 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) { + wlr_log(WLR_ERROR, "Failed to create XKB keymap"); + exit(1); + } + wlr_keyboard_set_keymap(device->keyboard, keymap); + xkb_keymap_unref(keymap); xkb_context_unref(context); break; default: -- cgit v1.2.3