1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 16:51:06 -07:00

src/bytecode.c: Add optional sanity check for jump tables.

* src/bytecode.c (exec_byte_code): When sanity checks are enabled,
  check that the jump table's size is equal to it's count.
This commit is contained in:
Vibhav Pant 2017-02-11 20:13:54 +05:30
parent c1a9b5db0e
commit 7c2d493540

View file

@ -1422,14 +1422,15 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
Lisp_Object v1 = POP;
ptrdiff_t i;
struct Lisp_Hash_Table *h = XHASH_TABLE(jmp_table);
/* Hash tables for switch are declared with :size set to the
exact number of cases. */
if (BYTE_CODE_SAFE)
eassert (HASH_TABLE_SIZE (h) == h->count);
if (h->count <= 5)
{ /* Do a linear search if there are not many cases
FIXME: 5 is arbitrarily chosen. */
EMACS_UINT hash_code = h->test.hashfn (&h->test, v1);
/* Hash tables for switch are declared with :size set to the
exact number of cases, thus
HASH_TABLE_SIZE (h) == h->count. */
for (i = 0; i < h->count; i++)
{
if (BYTE_CODE_SAFE)