aboutsummaryrefslogtreecommitdiff
path: root/examples/simple.c
diff options
context:
space:
mode:
authorrandom human <random.bored.human@gmail.com>2018-09-02 21:16:24 +0530
committerrandom human <random.bored.human@gmail.com>2018-09-03 02:43:44 +0530
commit7105864e13c7a83f57d22edce619fe511a9d1342 (patch)
tree4a1ef9e245c20f04e032fd3e09d7974ae0f1075c /examples/simple.c
parent7bc26579844b2027bcc5fdde5b6978ea108f3edf (diff)
Handle setting keymap in examples more securely
Diffstat (limited to 'examples/simple.c')
-rw-r--r--examples/simple.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/examples/simple.c b/examples/simple.c
index 1125bd2a..e1c10906 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -141,8 +141,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: