mirror of
https://github.com/swaywm/sway.git
synced 2026-04-23 06:46:27 -04:00
Fix segfault when connecting keyboard/mouse
Sometimes `device->wlr_device->keyboard->keymap` is NULL. When that happens, the call to `xkb_keymap_num_layouts` segfaults. This adds a guard around the handling of `keymap` to prevent that. This should resolve issues #6502 #6484
This commit is contained in:
parent
ffc603d451
commit
6f0b5b9cb3
1 changed files with 15 additions and 13 deletions
|
|
@ -989,6 +989,7 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
|
||||||
json_object *layouts_arr = json_object_new_array();
|
json_object *layouts_arr = json_object_new_array();
|
||||||
json_object_object_add(object, "xkb_layout_names", layouts_arr);
|
json_object_object_add(object, "xkb_layout_names", layouts_arr);
|
||||||
|
|
||||||
|
if (keymap) {
|
||||||
xkb_layout_index_t num_layouts = xkb_keymap_num_layouts(keymap);
|
xkb_layout_index_t num_layouts = xkb_keymap_num_layouts(keymap);
|
||||||
xkb_layout_index_t layout_idx;
|
xkb_layout_index_t layout_idx;
|
||||||
for (layout_idx = 0; layout_idx < num_layouts; layout_idx++) {
|
for (layout_idx = 0; layout_idx < num_layouts; layout_idx++) {
|
||||||
|
|
@ -1006,6 +1007,7 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
|
if (device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
|
||||||
struct input_config *ic = input_device_get_config(device);
|
struct input_config *ic = input_device_get_config(device);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue