x11: don't trust keycode before testing its range

The assert is not very useful access the key just before.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2014-02-09 18:02:11 +02:00
parent 27a245891b
commit 8be2608a26
1 changed files with 7 additions and 3 deletions

View File

@ -536,11 +536,13 @@ get_explicits(struct xkb_keymap *keymap, xcb_connection_t *conn,
for (int i = 0; i < length; i++) {
xcb_xkb_set_explicit_t *wire = iter.data;
struct xkb_key *key = &keymap->keys[wire->keycode];
struct xkb_key *key;
FAIL_UNLESS(wire->keycode >= keymap->min_key_code &&
wire->keycode <= keymap->max_key_code);
key = &keymap->keys[wire->keycode];
if ((wire->explicit & XCB_XKB_EXPLICIT_KEY_TYPE_1) &&
key->num_groups > 0)
key->groups[0].explicit_type = true;
@ -579,11 +581,12 @@ get_modmaps(struct xkb_keymap *keymap, xcb_connection_t *conn,
for (int i = 0; i < length; i++) {
xcb_xkb_key_mod_map_t *wire = iter.data;
struct xkb_key *key = &keymap->keys[wire->keycode];
struct xkb_key *key;
FAIL_UNLESS(wire->keycode >= keymap->min_key_code &&
wire->keycode <= keymap->max_key_code);
key = &keymap->keys[wire->keycode];
key->modmap = wire->mods;
xcb_xkb_key_mod_map_next(&iter);
@ -605,11 +608,12 @@ get_vmodmaps(struct xkb_keymap *keymap, xcb_connection_t *conn,
for (int i = 0; i < length; i++) {
xcb_xkb_key_v_mod_map_t *wire = iter.data;
struct xkb_key *key = &keymap->keys[wire->keycode];
struct xkb_key *key;
FAIL_UNLESS(wire->keycode >= keymap->min_key_code &&
wire->keycode <= keymap->max_key_code);
key = &keymap->keys[wire->keycode];
key->vmodmap = translate_mods(0, wire->vmods, 0);
xcb_xkb_key_v_mod_map_next(&iter);