state: missing XKB_EXPORT on xkb_state_key_get_level
authorRan Benita <ran234@gmail.com>
Fri, 21 Sep 2012 18:16:20 +0000 (21:16 +0300)
committerDaniel Stone <daniel@fooishbar.org>
Sun, 23 Sep 2012 23:08:54 +0000 (09:08 +1000)
And some error handling.

Signed-off-by: Ran Benita <ran234@gmail.com>
src/state.c

index bfe35bb..ef770cc 100644 (file)
@@ -128,13 +128,16 @@ get_entry_for_key_state(struct xkb_state *state, const struct xkb_key *key,
  * Returns the level to use for the given key and state, or
  * XKB_LEVEL_INVALID.
  */
-xkb_level_index_t
+XKB_EXPORT xkb_level_index_t
 xkb_state_key_get_level(struct xkb_state *state, xkb_keycode_t kc,
                         xkb_layout_index_t layout)
 {
     const struct xkb_key *key = XkbKey(state->keymap, kc);
     struct xkb_kt_map_entry *entry;
 
+    if (!key || layout >= key->num_groups)
+        return XKB_LEVEL_INVALID;
+
     /* If we don't find an explicit match the default is 0. */
     entry = get_entry_for_key_state(state, key, layout);
     if (!entry)