From f43b33c02fe6081bc1a04087974c52c96f6fee35 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 13 Oct 2012 13:13:55 +0200 Subject: [PATCH] state: make mod_index_is_consumed() return -1 on invalid input Like all the other functions. Signed-off-by: Ran Benita --- src/state.c | 4 ++-- xkbcommon/xkbcommon.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/state.c b/src/state.c index 1511342..4c159fc 100644 --- a/src/state.c +++ b/src/state.c @@ -1052,8 +1052,8 @@ xkb_state_mod_index_is_consumed(struct xkb_state *state, xkb_keycode_t kc, { const struct xkb_key *key = XkbKey(state->keymap, kc); - if (!key) - return 0; + if (!key || idx >= xkb_keymap_num_mods(state->keymap)) + return -1; return !!((1 << idx) & key_get_consumed(state, key)); } diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h index 2cbf2cc..299b61c 100644 --- a/xkbcommon/xkbcommon.h +++ b/xkbcommon/xkbcommon.h @@ -890,8 +890,8 @@ xkb_state_mod_indices_are_active(struct xkb_state *state, /** * Returns 1 if the modifier specified by 'idx' is used in the * translation of the keycode 'key' to the key symbols obtained by - * pressing it (as in xkb_key_get_syms), given the current state. - * Returns 0 otherwise. + * pressing it (as in xkb_state_key_get_syms), given the current state, + * 0 otherwise, or -1 if the index is invalid in the keymap. */ int xkb_state_mod_index_is_consumed(struct xkb_state *state, xkb_keycode_t key, -- 2.7.4