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>
This commit is contained in:
parent
b6c7780bb0
commit
fbf40c1d90
1 changed files with 9 additions and 7 deletions
16
src/lisp.h
16
src/lisp.h
|
@ -1671,6 +1671,13 @@ ASIZE (Lisp_Object array)
|
|||
return size;
|
||||
}
|
||||
|
||||
INLINE ptrdiff_t
|
||||
gc_asize (Lisp_Object array)
|
||||
{
|
||||
/* Like ASIZE, but also can be used in the garbage collector. */
|
||||
return XVECTOR (array)->header.size & ~ARRAY_MARK_FLAG;
|
||||
}
|
||||
|
||||
INLINE ptrdiff_t
|
||||
PVSIZE (Lisp_Object pv)
|
||||
{
|
||||
|
@ -1853,22 +1860,17 @@ bool_vector_set (Lisp_Object a, EMACS_INT i, bool b)
|
|||
INLINE Lisp_Object
|
||||
AREF (Lisp_Object array, ptrdiff_t idx)
|
||||
{
|
||||
eassert (0 <= idx && idx < gc_asize (array));
|
||||
return XVECTOR (array)->contents[idx];
|
||||
}
|
||||
|
||||
INLINE Lisp_Object *
|
||||
aref_addr (Lisp_Object array, ptrdiff_t idx)
|
||||
{
|
||||
eassert (0 <= idx && idx <= gc_asize (array));
|
||||
return & XVECTOR (array)->contents[idx];
|
||||
}
|
||||
|
||||
INLINE ptrdiff_t
|
||||
gc_asize (Lisp_Object array)
|
||||
{
|
||||
/* Like ASIZE, but also can be used in the garbage collector. */
|
||||
return XVECTOR (array)->header.size & ~ARRAY_MARK_FLAG;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
ASET (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue