summaryrefslogtreecommitdiff
path: root/src/state.c
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2014-02-09 13:51:38 +0200
committerRan Benita <ran234@gmail.com>2014-02-09 14:09:42 +0200
commite89516e97634c2047c52d0cd9380050e4b945188 (patch)
treea82cbfc8873a4e7042e261acd32ec237e60205a2 /src/state.c
parentd53eef0d9411a94cdb0f21e2cd6cb072ea387377 (diff)
downloadxorg-lib-libxkbcommon-e89516e97634c2047c52d0cd9380050e4b945188.tar.gz
state: check wrap_group_into_range() return value
It returns XKB_LAYOUT_INVALID in case num_groups == 0. So we shouldn't just save it in the state. Note, though, that this condition is generally impossible. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/state.c b/src/state.c
index 41372f5..8b1a526 100644
--- a/src/state.c
+++ b/src/state.c
@@ -668,23 +668,27 @@ xkb_state_led_update_all(struct xkb_state *state)
static void
xkb_state_update_derived(struct xkb_state *state)
{
+ xkb_layout_index_t wrapped;
+
state->components.mods = (state->components.base_mods |
state->components.latched_mods |
state->components.locked_mods);
/* TODO: Use groups_wrap control instead of always RANGE_WRAP. */
+ wrapped = wrap_group_into_range(state->components.locked_group,
+ state->keymap->num_groups,
+ RANGE_WRAP, 0);
state->components.locked_group =
- wrap_group_into_range(state->components.locked_group,
- state->keymap->num_groups,
- RANGE_WRAP, 0);
+ (wrapped == XKB_LAYOUT_INVALID ? 0 : wrapped);
+ wrapped = wrap_group_into_range(state->components.base_group +
+ state->components.latched_group +
+ state->components.locked_group,
+ state->keymap->num_groups,
+ RANGE_WRAP, 0);
state->components.group =
- wrap_group_into_range(state->components.base_group +
- state->components.latched_group +
- state->components.locked_group,
- state->keymap->num_groups,
- RANGE_WRAP, 0);
+ (wrapped == XKB_LAYOUT_INVALID ? 0 : wrapped);
xkb_state_led_update_all(state);
}