x11: add #actions == #syms check
authorRan Benita <ran234@gmail.com>
Fri, 7 Feb 2014 15:13:03 +0000 (17:13 +0200)
committerRan Benita <ran234@gmail.com>
Fri, 7 Feb 2014 15:13:03 +0000 (17:13 +0200)
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 <ran234@gmail.com>
src/x11/keymap.c

index fa32d16bd73648ab1103d2ea2588dbd1794ac483..0eedb302a36646f7e8e99bab3350230a40a70047 100644 (file)
@@ -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;