diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-07-20 19:40:03 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-07-20 20:13:46 -0700 |
commit | 515afc9c15870cd7bd6b96e2d8b89938116923ac (patch) | |
tree | e57bf126a8e6076edb1c4fa87e4908c94fd8d779 /src/alloc.c | |
parent | b6f194a0fb6dbd1b19aa01f95a955f5b8b23b40e (diff) | |
download | emacs-515afc9c15870cd7bd6b96e2d8b89938116923ac.tar.gz |
Fix crash if user test munges hash table
* src/fns.c (restore_mutability)
(hash_table_user_defined_call): New functions.
(cmpfn_user_defined, hashfn_user_defined): Use them.
(make_hash_table, copy_hash_table):
Mark new hash table as mutable.
(check_mutable_hash_table): New function.
(Fclrhash, Fputhash, Fremhash): Use it instead of CHECK_IMPURE.
* src/lisp.h (struct hash_table_test): User-defined functions
now take pointers to struct Lisp_Hash_Table, not to struct
hash_table_test. All uses changed.
(struct Lisp_Hash_Table): New member ‘mutable’.
* src/pdumper.c (dump_hash_table): Copy it.
* test/src/fns-tests.el (test-hash-function-that-mutates-hash-table):
New test, which tests for the bug.
Diffstat (limited to 'src/alloc.c')
-rw-r--r-- | src/alloc.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/alloc.c b/src/alloc.c index 09b3a4ea7e4..1718ce0fafc 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -5352,6 +5352,7 @@ purecopy_hash_table (struct Lisp_Hash_Table *table) pure->count = table->count; pure->next_free = table->next_free; pure->purecopy = table->purecopy; + eassert (!pure->mutable); pure->rehash_threshold = table->rehash_threshold; pure->rehash_size = table->rehash_size; pure->key_and_value = purecopy (table->key_and_value); |