changeset 91717:23bd9edca21f

(ASET): Check bounds.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 10 Feb 2008 03:20:40 +0000
parents 5bb2c18b8034
children 89610dccd10a
files src/ChangeLog src/lisp.h
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Feb 10 03:16:06 2008 +0000
+++ b/src/ChangeLog	Sun Feb 10 03:20:40 2008 +0000
@@ -1,3 +1,7 @@
+2008-02-10  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* lisp.h (ASET): Check bounds.
+
 2008-02-10  Glenn Morris  <rgm@gnu.org>
 
 	* buffer.c (mode-name): Doc fix.
--- a/src/lisp.h	Sun Feb 10 03:16:06 2008 +0000
+++ b/src/lisp.h	Sun Feb 10 03:20:40 2008 +0000
@@ -589,8 +589,12 @@
 /* Convenience macros for dealing with Lisp arrays.  */
 
 #define AREF(ARRAY, IDX)	XVECTOR ((ARRAY))->contents[IDX]
-#define ASET(ARRAY, IDX, VAL)	(AREF ((ARRAY), (IDX)) = (VAL))
 #define ASIZE(ARRAY)		XVECTOR ((ARRAY))->size
+/* The IDX==IDX tries to detect when the macro argument is side-effecting.  */
+#define ASET(ARRAY, IDX, VAL)	\
+  (eassert ((IDX) == (IDX)),				\
+   eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)),	\
+   ASLOT ((ARRAY), (IDX)) = (VAL))
 
 /* Convenience macros for dealing with Lisp strings.  */