summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2012-03-22 14:31:33 +0000
committerDaniel Stone <daniel@fooishbar.org>2012-03-22 14:31:33 +0000
commit504cc0b858fefac8ea7e8911e60c1b961e225ec4 (patch)
treef5c3aad100033c6b8730241338a3216c53b5eb16 /src
parentcfb07724b7a5572e653a394f7c986ad6b5ee5fc8 (diff)
downloadxorg-lib-libxkbcommon-504cc0b858fefac8ea7e8911e60c1b961e225ec4.tar.gz
Check for invalid indices in mod/group state API
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'src')
-rw-r--r--src/state.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/state.c b/src/state.c
index d63d4c9..1802f84 100644
--- a/src/state.c
+++ b/src/state.c
@@ -472,6 +472,9 @@ int xkb_state_mod_index_is_active(struct xkb_state *state,
{
int ret = 0;
+ if (idx >= xkb_map_num_mods(state->xkb))
+ return -1;
+
if (type & XKB_STATE_DEPRESSED)
ret |= (state->base_mods & (1 << idx));
if (type & XKB_STATE_LATCHED)
@@ -507,6 +510,9 @@ int xkb_state_group_index_is_active(struct xkb_state *state,
{
int ret = 0;
+ if (idx >= xkb_map_num_groups(state->xkb))
+ return -1;
+
if (type & XKB_STATE_DEPRESSED)
ret |= (state->base_group == idx);
if (type & XKB_STATE_LATCHED)