--- gdkkeys-x11.c.jkj	2005-09-18 12:28:13.000000000 -0700
+++ gdkkeys-x11.c	2005-09-18 12:29:47.000000000 -0700
@@ -220,13 +220,25 @@
   int index;
 
   index = KEYSYM_INDEX(keymap_x11, group, level);
-  if (index > keymap_x11->keysyms_per_keycode)
+  if (index >= keymap_x11->keysyms_per_keycode)
       return NoSymbol;
 
   return syms[index];
 }
 
 static void
+set_symbol (KeySym *syms, GdkKeymapX11 *keymap_x11, int group, int level, KeySym sym)
+{
+  int index;
+
+  index = KEYSYM_INDEX(keymap_x11, group, level);
+  if (index >= keymap_x11->keysyms_per_keycode)
+      return;
+
+  syms[index] = sym;
+}
+
+static void
 update_keymaps (GdkKeymapX11 *keymap_x11)
 {
   GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_KEYMAP (keymap_x11)->display);
@@ -271,7 +283,7 @@
 	  for (i = 0 ; i < 2 ; i++)
 	    {
 	      if (get_symbol (syms, keymap_x11, i, 0) == GDK_Tab)
-		syms[KEYSYM_INDEX (keymap_x11, i, 1)] = GDK_ISO_Left_Tab;
+		set_symbol (syms, keymap_x11, i, 1, GDK_ISO_Left_Tab);
 	    }
 
           /*
@@ -286,8 +298,8 @@
               gdk_keyval_convert_case (get_symbol (syms, keymap_x11, 0, 0), &lower, &upper);
               if (lower != upper)
                 {
-                  syms[KEYSYM_INDEX (keymap_x11, 0, 0)] = lower;
-                  syms[KEYSYM_INDEX (keymap_x11, 0, 1)] = upper;
+		  set_symbol (syms, keymap_x11, 0, 0, lower);
+		  set_symbol (syms, keymap_x11, 0, 0, upper);
                 }
             }
       
