Index: scheme.c
===================================================================
--- scheme.c	(revision 22131)
+++ scheme.c	(working copy)
@@ -768,13 +768,19 @@
 static pointer oblist_add_by_name(scheme *sc, const char *name)
 {
   pointer x;
+  pointer s;
   int location;
 
-  x = immutable_cons(sc, mk_string(sc, name), sc->NIL);
+  g_assert (sc != NULL);
+  g_assert (name != NULL);
+
+  /* case-insensitive, per R5RS section 2. */
+  s = mk_string(sc, name);
+  x = immutable_cons(sc, s, sc->NIL);
   typeflag(x) = T_SYMBOL;
   setimmutable(car(x));
 
-  location = hash_fn(name, ivalue_unchecked(sc->oblist));
+  location = hash_fn(strkey(s), ivalue_unchecked(sc->oblist));
   set_vector_elem(sc->oblist, location,
                   immutable_cons(sc, x, vector_elem(sc->oblist, location)));
   return x;
@@ -792,7 +798,7 @@
   key = g_utf8_collate_key(s, -1);
   g_free(s);
 
-  location = hash_fn(name, ivalue_unchecked(sc->oblist));
+  location = hash_fn(key, ivalue_unchecked(sc->oblist));
   for (x = vector_elem(sc->oblist, location); x != sc->NIL; x = cdr(x)) {
     s = symkey(car(x));
     if(strcmp(key, s) == 0) {
@@ -2117,6 +2122,9 @@
   const char *c;
   int bits_per_int = sizeof(unsigned int)*8;
 
+  g_assert (key != NULL);
+  g_assert (table_size > 0);
+
   for (c = key; *c; c++) {
     /* letters have about 5 bits in them */
     hashed = (hashed<<5) | (hashed>>(bits_per_int-5));
@@ -2157,7 +2165,7 @@
   pointer slot = immutable_cons(sc, variable, value);
 
   if (is_vector(car(env))) {
-    int location = hash_fn(symname(variable), ivalue_unchecked(car(env)));
+    int location = hash_fn(symkey(variable), ivalue_unchecked(car(env)));
 
     set_vector_elem(car(env), location,
                     immutable_cons(sc, slot, vector_elem(car(env), location)));
@@ -2171,9 +2179,12 @@
   pointer x,y;
   int location;
 
+  g_assert (env != NULL);
+  g_assert (hdl != NULL);
+
   for (x = env; x != sc->NIL; x = cdr(x)) {
     if (is_vector(car(x))) {
-      location = hash_fn(symname(hdl), ivalue_unchecked(car(x)));
+      location = hash_fn(symkey(hdl), ivalue_unchecked(car(x)));
       y = vector_elem(car(x), location);
     } else {
       y = car(x);
