aboutsummaryrefslogtreecommitdiff
path: root/examples
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
parent7bc26579844b2027bcc5fdde5b6978ea108f3edf (diff)
Handle setting keymap in examples more securely
Diffstat (limited to 'examples')
-rw-r--r--examples/multi-pointer.c14
-rw-r--r--examples/output-layout.c10
-rw-r--r--examples/pointer.c10
-rw-r--r--examples/rotation.c10
-rw-r--r--examples/simple.c10
-rw-r--r--examples/tablet.c10
-rw-r--r--examples/touch.c10
7 files changed, 58 insertions, 16 deletions
diff --git a/examples/multi-pointer.c b/examples/multi-pointer.c
index 958e90f6..87beafab 100644
--- a/examples/multi-pointer.c
+++ b/examples/multi-pointer.c
@@ -239,15 +239,21 @@ 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;
case WLR_INPUT_DEVICE_POINTER:;
- struct sample_cursor *cursor = calloc(1, sizeof(struct sample_cursor));
+ struct sample_cursor *cursor = calloc(1, sizeof(struct sample_cursor));
struct sample_pointer *pointer = calloc(1, sizeof(struct sample_pointer));
pointer->device = device;
- cursor->sample = sample;
+ cursor->sample = sample;
cursor->device = device;
cursor->cursor = wlr_cursor_create();
diff --git a/examples/output-layout.c b/examples/output-layout.c
index 2bfc5923..3f9cf84e 100644
--- a/examples/output-layout.c
+++ b/examples/output-layout.c
@@ -239,8 +239,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:
diff --git a/examples/pointer.c b/examples/pointer.c
index f0d9fb4b..cc58c223 100644
--- a/examples/pointer.c
+++ b/examples/pointer.c
@@ -304,8 +304,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:
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:
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:
diff --git a/examples/tablet.c b/examples/tablet.c
index 4817db4d..fad30d52 100644
--- a/examples/tablet.c
+++ b/examples/tablet.c
@@ -297,8 +297,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;
case WLR_INPUT_DEVICE_TABLET_PAD:;
diff --git a/examples/touch.c b/examples/touch.c
index ba5d1e34..9ed20a28 100644
--- a/examples/touch.c
+++ b/examples/touch.c
@@ -210,8 +210,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;
case WLR_INPUT_DEVICE_TOUCH:;