mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 20:03:10 +02:00
wayland: use xkb_keymap_new_from_buffer
Instead of `xkb_keymap_new_from_string`. The protocol does not require the keymap to be null terminated and if the size of the keymap is a multiple of the page size, using `_from_string` could lead to problems. Some compositors include a null byte and even include the null byte in `size`. Therefore we have to use `strnlen` to find the real length of the string. Note that `_from_string` internally uses `strlen` and then calls `_from_buffer`.
This commit is contained in:
parent
3978669ece
commit
777628e761
@ -350,7 +350,8 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard,
|
||||
return;
|
||||
}
|
||||
|
||||
wl->xkb_keymap = xkb_keymap_new_from_string(wl->xkb_context, map_str,
|
||||
wl->xkb_keymap = xkb_keymap_new_from_buffer(wl->xkb_context, map_str,
|
||||
strnlen(map_str, size),
|
||||
XKB_KEYMAP_FORMAT_TEXT_V1, 0);
|
||||
|
||||
munmap(map_str, size);
|
||||
|
Loading…
Reference in New Issue
Block a user