From: Stefan Monnier Date: Sun, 10 Feb 2008 03:20:40 +0000 (+0000) Subject: (ASET): Check bounds. X-Git-Tag: emacs-pretest-23.0.90~8046 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4b75ffab30b7764136732398319d33d7104cae68;p=emacs.git (ASET): Check bounds. --- diff --git a/src/ChangeLog b/src/ChangeLog index afc6603da5e..b3ffe08f3ba 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2008-02-10 Stefan Monnier + + * lisp.h (ASET): Check bounds. + 2008-02-10 Glenn Morris * buffer.c (mode-name): Doc fix. diff --git a/src/lisp.h b/src/lisp.h index 5156386551a..daa45d3aad8 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -589,8 +589,12 @@ extern size_t pure_size; /* 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. */