summaryrefslogtreecommitdiff
path: root/src/composite.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-07-20 19:40:03 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-07-20 20:13:46 -0700
commit515afc9c15870cd7bd6b96e2d8b89938116923ac (patch)
treee57bf126a8e6076edb1c4fa87e4908c94fd8d779 /src/composite.c
parentb6f194a0fb6dbd1b19aa01f95a955f5b8b23b40e (diff)
downloademacs-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/composite.c')
-rw-r--r--src/composite.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/composite.c b/src/composite.c
index c36663f8e97..a6606d5fc45 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -655,7 +655,7 @@ composition_gstring_put_cache (Lisp_Object gstring, ptrdiff_t len)
struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table);
hash_rehash_if_needed (h);
Lisp_Object header = LGSTRING_HEADER (gstring);
- Lisp_Object hash = h->test.hashfn (header, &h->test);
+ Lisp_Object hash = h->test.hashfn (header, h);
if (len < 0)
{
ptrdiff_t glyph_len = LGSTRING_GLYPH_LEN (gstring);