summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2020-11-08 10:30:49 -0600
committerDudemanguy <random342@airmail.cc>2020-11-08 10:59:41 -0600
commit4c4d9d6d5249f2fc35e05c71d01775b040198073 (patch)
tree3f491e8fb89429f3394a578483bc5539e1a77545 /video/out
parentcf00b0b990fce8ab128034fc4084d86e92cfbd4f (diff)
downloadmpv-4c4d9d6d5249f2fc35e05c71d01775b040198073.tar.bz2
mpv-4c4d9d6d5249f2fc35e05c71d01775b040198073.tar.xz
wayland: fix buffer overrun in get_mods
Use MP_ARRAY_SIZE and make the mod arrays here const.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/wayland_common.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index beb2a16316..38b9ca0a8c 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -127,21 +127,21 @@ static int set_cursor_visibility(struct vo_wayland_state *wl, bool on)
static int get_mods(struct vo_wayland_state *wl)
{
- static const char *mod_names[] = {
+ static char* const mod_names[] = {
XKB_MOD_NAME_SHIFT,
XKB_MOD_NAME_CTRL,
XKB_MOD_NAME_ALT,
XKB_MOD_NAME_LOGO,
};
- static int mods[] = {
+ static const int mods[] = {
MP_KEY_MODIFIER_SHIFT,
MP_KEY_MODIFIER_CTRL,
MP_KEY_MODIFIER_ALT,
MP_KEY_MODIFIER_META,
};
- for (int n = 0; mods[n]; n++) {
+ for (int n = 0; n < MP_ARRAY_SIZE(mods); n++) {
xkb_mod_index_t index = xkb_keymap_mod_get_index(wl->xkb_keymap, mod_names[n]);
if (!xkb_state_mod_index_is_consumed(wl->xkb_state, wl->keyboard_code, index)
&& xkb_state_mod_index_is_active(wl->xkb_state, index,