diff options
| author | Eli Zaretskii | 2020-10-26 18:14:32 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2020-10-26 18:14:32 +0200 |
| commit | 634bbb61f2f1b3e0fdf830f58a7ec7e39ea5a14f (patch) | |
| tree | 529545df5e1424558c06b2224a54836929b6a5e7 /src/composite.c | |
| parent | cdb3c9d662c772ce25ea4d803eccd2c9e6a6ae99 (diff) | |
| download | emacs-634bbb61f2f1b3e0fdf830f58a7ec7e39ea5a14f.tar.gz emacs-634bbb61f2f1b3e0fdf830f58a7ec7e39ea5a14f.zip | |
Avoid segfaults due to using fonts that were closed
* src/composite.c (composition_gstring_cache_clear_font): New
function.
* src/composite.h (composition_gstring_cache_clear_font): Add
prototype.
* src/font.c (font_clear_cache): When we are about to close a
font, remove from the gstring cache any lgstring that uses this
font. (Bug#42943)
Diffstat (limited to 'src/composite.c')
| -rw-r--r-- | src/composite.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/composite.c b/src/composite.c index 90f8536b2de..66c1e86aae1 100644 --- a/src/composite.c +++ b/src/composite.c | |||
| @@ -677,6 +677,27 @@ composition_gstring_from_id (ptrdiff_t id) | |||
| 677 | return HASH_VALUE (h, id); | 677 | return HASH_VALUE (h, id); |
| 678 | } | 678 | } |
| 679 | 679 | ||
| 680 | /* Remove from the composition hash table every lgstring that | ||
| 681 | references the given FONT_OBJECT. */ | ||
| 682 | void | ||
| 683 | composition_gstring_cache_clear_font (Lisp_Object font_object) | ||
| 684 | { | ||
| 685 | struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); | ||
| 686 | |||
| 687 | for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i) | ||
| 688 | { | ||
| 689 | Lisp_Object k = HASH_KEY (h, i); | ||
| 690 | |||
| 691 | if (!EQ (k, Qunbound)) | ||
| 692 | { | ||
| 693 | Lisp_Object gstring = HASH_VALUE (h, i); | ||
| 694 | |||
| 695 | if (EQ (LGSTRING_FONT (gstring), font_object)) | ||
| 696 | hash_remove_from_table (h, k); | ||
| 697 | } | ||
| 698 | } | ||
| 699 | } | ||
| 700 | |||
| 680 | DEFUN ("clear-composition-cache", Fclear_composition_cache, | 701 | DEFUN ("clear-composition-cache", Fclear_composition_cache, |
| 681 | Sclear_composition_cache, 0, 0, 0, | 702 | Sclear_composition_cache, 0, 0, 0, |
| 682 | doc: /* Internal use only. | 703 | doc: /* Internal use only. |