Index: gdkkeys-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkkeys-x11.c,v
retrieving revision 1.40.2.1
diff -u -r1.40.2.1 gdkkeys-x11.c
--- gdkkeys-x11.c	10 May 2004 20:49:35 -0000	1.40.2.1
+++ gdkkeys-x11.c	22 Jun 2004 16:48:05 -0000
@@ -212,6 +212,19 @@
 #define KEYSYM_IS_KEYPAD(s) (((s) >= 0xff80 && (s) <= 0xffbd) || \
                              ((s) >= 0x11000000 && (s) <= 0x1100ffff))
 
+static int
+get_symbol (const KeySym *syms, GdkKeymapX11 *keymap_x11, int group, int level)
+{
+  int index;
+
+  index = KEYSYM_INDEX(keymap_x11, group, level);
+  if (index > keymap_x11->keysyms_per_keycode) {
+    return NoSymbol;
+  }
+
+  return syms[index];
+}
+
 static void
 update_keymaps (GdkKeymapX11 *keymap_x11)
 {
@@ -256,7 +269,7 @@
 	  /* Check both groups */
 	  for (i = 0 ; i < 2 ; i++)
 	    {
-	      if (syms[KEYSYM_INDEX (keymap_x11, i, 0)] == GDK_Tab)
+	      if (get_symbol (syms, keymap_x11, i, 0) == GDK_Tab)
 		syms[KEYSYM_INDEX (keymap_x11, i, 1)] = GDK_ISO_Left_Tab;
 	    }
 
@@ -264,12 +277,12 @@
            * If there is one keysym and the key symbol has upper and lower
            * case variants fudge the keymap
            */
-          if (syms[KEYSYM_INDEX (keymap_x11, 0, 1)] == 0)
+          if (get_symbol (syms, keymap_x11, 0, 1) == 0)
             {
               guint lower;
               guint upper;
 
-              gdk_keyval_convert_case (syms[KEYSYM_INDEX (keymap_x11, 0, 0)], &lower, &upper);
+              gdk_keyval_convert_case (get_symbol (syms, keymap_x11, 0, 0), &lower, &upper);
               if (lower != upper)
                 {
                   syms[KEYSYM_INDEX (keymap_x11, 0, 0)] = lower;
@@ -845,7 +858,7 @@
     {
       const KeySym *map = get_keymap (keymap_x11);
       const KeySym *syms = map + (key->keycode - keymap_x11->min_keycode) * keymap_x11->keysyms_per_keycode;
-      return syms [KEYSYM_INDEX (keymap_x11, key->group, key->level)];
+      return get_symbol (syms, keymap_x11, key->group, key->level);
     }
 }
 
@@ -995,7 +1008,7 @@
   const KeySym *map = get_keymap (keymap_x11);
   const KeySym *syms = map + (hardware_keycode - keymap_x11->min_keycode) * keymap_x11->keysyms_per_keycode;
 
-#define SYM(k,g,l) syms[KEYSYM_INDEX (k,g,l)]
+#define SYM(k,g,l) get_symbol (syms, k,g,l)
 
   GdkModifierType shift_modifiers;
   gint shift_level;
