From ed18f7dde661e63528a12a63a32d2dceecec01bb Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 7 Feb 2014 17:13:03 +0200 Subject: [PATCH] x11: add #actions == #syms check This must always hold (but if there are no actions, #actions==0), and explicitly ensures there won't be a division-by-zero a bit below. Signed-off-by: Ran Benita --- src/x11/keymap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/x11/keymap.c b/src/x11/keymap.c index fa32d16..0eedb30 100644 --- a/src/x11/keymap.c +++ b/src/x11/keymap.c @@ -471,9 +471,12 @@ get_actions(struct xkb_keymap *keymap, xcb_connection_t *conn, for (int i = 0; i < acts_count_length; i++) { xcb_xkb_key_sym_map_t *wire_sym_map = sym_maps_iter.data; + int syms_length = xcb_xkb_key_sym_map_syms_length(wire_sym_map); uint8_t wire_count = *acts_count_iter; struct xkb_key *key = &keymap->keys[reply->firstKeyAction + i]; + FAIL_UNLESS(wire_count == 0 || wire_count == syms_length); + for (int j = 0; j < wire_count; j++) { xcb_xkb_action_t *wire_action = acts_iter.data; const xkb_layout_index_t group = j / wire_sym_map->width; -- 2.7.4