changeset 31496:946e1ba42cc9

(Fset_keymap_parent): Check for cycles in keymap inheritance.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 08 Sep 2000 13:30:03 +0000
parents 1cec17cdcff1
children 03cff4e91e67
files src/keymap.c
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/keymap.c	Fri Sep 08 13:14:07 2000 +0000
+++ b/src/keymap.c	Fri Sep 08 13:30:03 2000 +0000
@@ -307,6 +307,7 @@
   return Qnil;
 }
 
+
 /* Set the parent keymap of MAP to PARENT.  */
 
 DEFUN ("set-keymap-parent", Fset_keymap_parent, Sset_keymap_parent, 2, 2, 0,
@@ -323,7 +324,18 @@
   GCPRO1 (keymap);
   
   if (!NILP (parent))
-    parent = get_keymap_1 (parent, 1, 1);
+    {
+      Lisp_Object k;
+      
+      parent = get_keymap_1 (parent, 1, 1);
+
+      /* Check for cycles.  */
+      k = parent;
+      while (KEYMAPP (k) && !EQ (keymap, k))
+	k = Fkeymap_parent (k);
+      if (EQ (keymap, k))
+	error ("Cyclic keymap inheritance");
+    }
 
   /* Skip past the initial element `keymap'.  */
   prev = keymap;