diff options
| author | Paul Eggert | 2020-06-18 14:01:56 -0700 |
|---|---|---|
| committer | Paul Eggert | 2020-06-18 14:02:42 -0700 |
| commit | fbf40c1d903d18286ecd7d2c1d7b117c88a1d5dd (patch) | |
| tree | fb9f54fe04fc6dedb6a95cee4ea77c03c76f19e4 | |
| parent | b6c7780bb02465e3af2ccec332fc2d8b79fe7a2a (diff) | |
| download | emacs-fbf40c1d903d18286ecd7d2c1d7b117c88a1d5dd.tar.gz emacs-fbf40c1d903d18286ecd7d2c1d7b117c88a1d5dd.zip | |
Check AREF and aref_addr subscripts
* src/lisp.h (gc_asize): Move before first use.
(AREF, aref_addr): Check subscripts.
Co-authored-by: Tino Calancha <tino.calancha@gmail.com>
| -rw-r--r-- | src/lisp.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lisp.h b/src/lisp.h index 34426990882..7b4f484b9b7 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1672,6 +1672,13 @@ ASIZE (Lisp_Object array) | |||
| 1672 | } | 1672 | } |
| 1673 | 1673 | ||
| 1674 | INLINE ptrdiff_t | 1674 | INLINE ptrdiff_t |
| 1675 | gc_asize (Lisp_Object array) | ||
| 1676 | { | ||
| 1677 | /* Like ASIZE, but also can be used in the garbage collector. */ | ||
| 1678 | return XVECTOR (array)->header.size & ~ARRAY_MARK_FLAG; | ||
| 1679 | } | ||
| 1680 | |||
| 1681 | INLINE ptrdiff_t | ||
| 1675 | PVSIZE (Lisp_Object pv) | 1682 | PVSIZE (Lisp_Object pv) |
| 1676 | { | 1683 | { |
| 1677 | return ASIZE (pv) & PSEUDOVECTOR_SIZE_MASK; | 1684 | return ASIZE (pv) & PSEUDOVECTOR_SIZE_MASK; |
| @@ -1853,22 +1860,17 @@ bool_vector_set (Lisp_Object a, EMACS_INT i, bool b) | |||
| 1853 | INLINE Lisp_Object | 1860 | INLINE Lisp_Object |
| 1854 | AREF (Lisp_Object array, ptrdiff_t idx) | 1861 | AREF (Lisp_Object array, ptrdiff_t idx) |
| 1855 | { | 1862 | { |
| 1863 | eassert (0 <= idx && idx < gc_asize (array)); | ||
| 1856 | return XVECTOR (array)->contents[idx]; | 1864 | return XVECTOR (array)->contents[idx]; |
| 1857 | } | 1865 | } |
| 1858 | 1866 | ||
| 1859 | INLINE Lisp_Object * | 1867 | INLINE Lisp_Object * |
| 1860 | aref_addr (Lisp_Object array, ptrdiff_t idx) | 1868 | aref_addr (Lisp_Object array, ptrdiff_t idx) |
| 1861 | { | 1869 | { |
| 1870 | eassert (0 <= idx && idx <= gc_asize (array)); | ||
| 1862 | return & XVECTOR (array)->contents[idx]; | 1871 | return & XVECTOR (array)->contents[idx]; |
| 1863 | } | 1872 | } |
| 1864 | 1873 | ||
| 1865 | INLINE ptrdiff_t | ||
| 1866 | gc_asize (Lisp_Object array) | ||
| 1867 | { | ||
| 1868 | /* Like ASIZE, but also can be used in the garbage collector. */ | ||
| 1869 | return XVECTOR (array)->header.size & ~ARRAY_MARK_FLAG; | ||
| 1870 | } | ||
| 1871 | |||
| 1872 | INLINE void | 1874 | INLINE void |
| 1873 | ASET (Lisp_Object array, ptrdiff_t idx, Lisp_Object val) | 1875 | ASET (Lisp_Object array, ptrdiff_t idx, Lisp_Object val) |
| 1874 | { | 1876 | { |