diff --git a/gdk/x11/gdkkeys-x11.c b/gdk/x11/gdkkeys-x11.c
index c45a971..8830a11 100644
--- a/gdk/x11/gdkkeys-x11.c
+++ b/gdk/x11/gdkkeys-x11.c
@@ -1101,6 +1101,7 @@ MyEnhancedXkbTranslateKeyCode(register XkbDescPtr     xkb,
         int found = 0;
 
         for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
+            g_assert (!entry->active || col+entry->level < XkbKeyNumSyms(xkb, key));
             if (!entry->active || syms[col+entry->level] == syms[col])
               continue;
             if (mods_rtrn) {
