changeset 104280:52ff955e0cc5

* buffer.c (set_buffer_internal_1) (swap_out_buffer_local_variables): Check for unbound local variables (Bug#4138).
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 15 Aug 2009 14:06:02 +0000
parents de38a863010a
children 222761334e34
files src/ChangeLog src/buffer.c
diffstat 2 files changed, 25 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat Aug 15 13:53:41 2009 +0000
+++ b/src/ChangeLog	Sat Aug 15 14:06:02 2009 +0000
@@ -1,3 +1,9 @@
+2009-08-15  Chong Yidong  <cyd@stupidchicken.com>
+
+	* buffer.c (set_buffer_internal_1)
+	(swap_out_buffer_local_variables): Check for unbound local
+	variables (Bug#4138).
+
 2009-08-14  Eli Zaretskii  <eliz@gnu.org>
 
 	* process.c (create_pty): Fix last change.
--- a/src/buffer.c	Sat Aug 15 13:53:41 2009 +0000
+++ b/src/buffer.c	Sat Aug 15 14:06:02 2009 +0000
@@ -1921,12 +1921,14 @@
 
   for (tail = b->local_var_alist; CONSP (tail); tail = XCDR (tail))
     {
-      valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
-      if ((BUFFER_LOCAL_VALUEP (valcontents))
+      if (CONSP (XCAR (tail))
+	  && SYMBOLP (XCAR (XCAR (tail)))
+	  && (valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))),
+	      (BUFFER_LOCAL_VALUEP (valcontents)))
 	  && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
 	      (BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem))))
-	/* Just reference the variable
-	     to cause it to become set for this buffer.  */
+	/* Just reference the variable to cause it to become set for
+	   this buffer.  */
 	Fsymbol_value (XCAR (XCAR (tail)));
     }
 
@@ -1935,12 +1937,14 @@
   if (old_buf)
     for (tail = old_buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
       {
-	valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
-	if ((BUFFER_LOCAL_VALUEP (valcontents))
+	if (CONSP (tail)
+	    && SYMBOLP (XCAR (XCAR (tail)))
+	    && (valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))),
+		(BUFFER_LOCAL_VALUEP (valcontents)))
 	    && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
 		(BOOLFWDP (tem) || INTFWDP (tem) || OBJFWDP (tem))))
-	  /* Just reference the variable
-               to cause it to become set for this buffer.  */
+	  /* Just reference the variable to cause it to become set for
+	     this buffer.  */
 	  Fsymbol_value (XCAR (XCAR (tail)));
       }
 }
@@ -2653,18 +2657,19 @@
 swap_out_buffer_local_variables (b)
      struct buffer *b;
 {
-  Lisp_Object oalist, alist, sym, tem, buffer;
+  Lisp_Object oalist, alist, sym, buffer;
 
   XSETBUFFER (buffer, b);
   oalist = b->local_var_alist;
 
   for (alist = oalist; CONSP (alist); alist = XCDR (alist))
     {
-      sym = XCAR (XCAR (alist));
-
-      /* Need not do anything if some other buffer's binding is now encached.  */
-      tem = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer;
-      if (EQ (tem, buffer))
+      if (CONSP (XCAR (alist))
+	  && (sym = XCAR (XCAR (alist)), SYMBOLP (sym))
+	  /* Need not do anything if some other buffer's binding is
+	     now encached.  */
+	  && EQ (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer,
+		 buffer))
 	{
 	  /* Symbol is set up for this buffer's old local value:
 	     swap it out!  */