APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1512203331 0
#      Sat Dec 02 08:28:51 2017 +0000
# Node ID 1f54a2879725779c7da8c8a3b22de821a595e049
# Parent  86ddcb2cb737db4e9518b1db0b7e4332a3d1b4d1
Add some circularity checking, bytecode.c, eval.c, keymap.c
src/ChangeLog addition:
2017-12-02  Aidan Kehoe  <kehoea(a)parhasard.net>
	* bytecode.c (set_compiled_function_arglist):
	Check that NEW_ is a true list, avoid having a circular list in
	the compiled funcction down the line.
	* debug.c (Fset_debug_classes_to_check):
	Use EXTERNAL_LIST_LOOP_3() looping through CLASSES for circularity
	checking, leave the type checking to it.
	* eval.c (Fmultiple_value_prog1):
	ARGS is an external list, check for circularity and
	well-formedness.
	* keymap.c (Fsingle_key_description):
	If KEY is a cons, loop using EXTERNAL_LIST_LOOP_3(), giving us
	type and circularity checking.
tests/ChangeLog addition:
2017-12-02  Aidan Kehoe  <kehoea(a)parhasard.net>
	* automated/keymap-tests.el:
	Test circularity checkcing in #'single-key-description.
diff -r 86ddcb2cb737 -r 1f54a2879725 src/ChangeLog
--- a/src/ChangeLog	Fri Dec 01 19:46:24 2017 +0000
+++ b/src/ChangeLog	Sat Dec 02 08:28:51 2017 +0000
@@ -1,3 +1,18 @@
+2017-12-02  Aidan Kehoe  <kehoea(a)parhasard.net>
+
+	* bytecode.c (set_compiled_function_arglist):
+	Check that NEW_ is a true list, avoid having a circular list in
+	the compiled funcction down the line.
+	* debug.c (Fset_debug_classes_to_check):
+	Use EXTERNAL_LIST_LOOP_3() looping through CLASSES for circularity
+	checking, leave the type checking to it.
+	* eval.c (Fmultiple_value_prog1):
+	ARGS is an external list, check for circularity and
+	well-formedness.
+	* keymap.c (Fsingle_key_description):
+	If KEY is a cons, loop using EXTERNAL_LIST_LOOP_3(), giving us
+	type and circularity checking.
+
 2017-11-30  Aidan Kehoe  <kehoea(a)parhasard.net>
 
 	* keymap.c (describe_command):
diff -r 86ddcb2cb737 -r 1f54a2879725 src/bytecode.c
--- a/src/bytecode.c	Fri Dec 01 19:46:24 2017 +0000
+++ b/src/bytecode.c	Sat Dec 02 08:28:51 2017 +0000
@@ -2681,7 +2681,7 @@
 static void
 set_compiled_function_arglist (Lisp_Compiled_Function *f, Lisp_Object new_)
 {
-  CHECK_LIST (new_);
+  CHECK_TRUE_LIST (new_);
   f->arglist = new_;
 
   /* Recalculate the optimized version of the function, since this depends
diff -r 86ddcb2cb737 -r 1f54a2879725 src/debug.c
--- a/src/debug.c	Fri Dec 01 19:46:24 2017 +0000
+++ b/src/debug.c	Sat Dec 02 08:28:51 2017 +0000
@@ -135,16 +135,12 @@
 */
        (classes))
 {
-  Lisp_Object rest;
-
-  CHECK_LIST (classes);
-
   /* Make sure all objects in the list are valid.  If anyone is not
      valid, reject the entire list without doing anything. */
-  LIST_LOOP (rest, classes)
+  EXTERNAL_LIST_LOOP_3 (elt, classes, rest)
     {
-      if (NILP (xemacs_debug_loop (X_VALIDATE, XCAR (rest), Qnil)))
-	sferror ("Invalid object in class list", Qunbound);
+      if (NILP (xemacs_debug_loop (X_VALIDATE, elt, Qnil)))
+        sferror ("Invalid object in class list", elt);
     }
 
   LIST_LOOP (rest, classes)
diff -r 86ddcb2cb737 -r 1f54a2879725 src/eval.c
--- a/src/eval.c	Fri Dec 01 19:46:24 2017 +0000
+++ b/src/eval.c	Sat Dec 02 08:28:51 2017 +0000
@@ -5081,7 +5081,7 @@
   GCPRO1 (val);
 
   {
-    LIST_LOOP_2 (form, XCDR (args))
+    EXTERNAL_LIST_LOOP_2 (form, XCDR (args))
       Feval (form);
   }
 
diff -r 86ddcb2cb737 -r 1f54a2879725 src/keymap.c
--- a/src/keymap.c	Fri Dec 01 19:46:24 2017 +0000
+++ b/src/keymap.c	Sat Dec 02 08:28:51 2017 +0000
@@ -3593,10 +3593,8 @@
     {
       DECLARE_EISTRING (bufp);
 
-      Lisp_Object rest;
-      LIST_LOOP (rest, key)
+      EXTERNAL_LIST_LOOP_3 (keysym, key, rest)
 	{
-	  Lisp_Object keysym = XCAR (rest);
 	  if (EQ (keysym, Qcontrol))    eicat_ascii (bufp, "C-");
 	  else if (EQ (keysym, Qctrl))  eicat_ascii (bufp, "C-");
 	  else if (EQ (keysym, Qmeta))  eicat_ascii (bufp, "M-");
diff -r 86ddcb2cb737 -r 1f54a2879725 tests/ChangeLog
--- a/tests/ChangeLog	Fri Dec 01 19:46:24 2017 +0000
+++ b/tests/ChangeLog	Sat Dec 02 08:28:51 2017 +0000
@@ -1,3 +1,8 @@
+2017-12-02  Aidan Kehoe  <kehoea(a)parhasard.net>
+
+	* automated/keymap-tests.el:
+	Test circularity checkcing in #'single-key-description.
+
 2017-11-23  Aidan Kehoe  <kehoea(a)parhasard.net>
 
 	* automated/format-tests.el (args-out-of-range):
diff -r 86ddcb2cb737 -r 1f54a2879725 tests/automated/keymap-tests.el
--- a/tests/automated/keymap-tests.el	Fri Dec 01 19:46:24 2017 +0000
+++ b/tests/automated/keymap-tests.el	Sat Dec 02 08:28:51 2017 +0000
@@ -133,4 +133,10 @@
 						      pi))
   (Check-Error wrong-type-argument (command-remapping 'describe-function-at-point
 						      nil pi)))
+
+;; Not quite a keymap test, but this function is in keymap.c, so add a test
+;; here:
  
+(Check-Error circular-list (single-key-description '#1=(control shift . #1#)))
+
+;;; end of keymap-tests.el
-- 
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after forty pints of stout’
(C. Moore)