summaryrefslogtreecommitdiff
path: root/src/xdisp.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2020-10-21 18:32:51 +0300
committerEli Zaretskii <eliz@gnu.org>2020-10-21 18:32:51 +0300
commite29cace60afdab04ff20c4f4043a3ee64ec9d01d (patch)
treed71100737cabd9b3d594d78fc3eeaced68bf274c /src/xdisp.c
parent18c0e20bea07cf4591b45800205cf25a927045f6 (diff)
downloademacs-e29cace60afdab04ff20c4f4043a3ee64ec9d01d.tar.gz
Avoid rare crashes while producing line numbers
* src/xdisp.c (maybe_produce_line_number): Prevent freeing of realized faces for as long as we are using lnum_face_id and current_lnum_face_id for producing glyphs. (Bug#44111)
Diffstat (limited to 'src/xdisp.c')
-rw-r--r--src/xdisp.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 6c401d0abb9..03dc4bec712 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22793,6 +22793,10 @@ maybe_produce_line_number (struct it *it)
int lnum_face_id = merge_faces (it->w, Qline_number, 0, DEFAULT_FACE_ID);
int current_lnum_face_id
= merge_faces (it->w, Qline_number_current_line, 0, DEFAULT_FACE_ID);
+ /* From here onwards, we must prevent freeing realized faces, because
+ we are using the above 2 face IDs for the glyphs we produce. */
+ bool save_free_realized_faces = inhibit_free_realized_faces;
+ inhibit_free_realized_faces = true;
/* Compute point's line number if needed. */
if ((EQ (Vdisplay_line_numbers, Qrelative)
|| EQ (Vdisplay_line_numbers, Qvisual)
@@ -22922,10 +22926,13 @@ maybe_produce_line_number (struct it *it)
it->lnum_width = 0;
it->lnum_pixel_width = 0;
bidi_unshelve_cache (itdata, false);
+ inhibit_free_realized_faces = save_free_realized_faces;
return;
}
}
+ inhibit_free_realized_faces = save_free_realized_faces;
+
/* Record the width in pixels we need for the line number display. */
it->lnum_pixel_width = tem_it.current_x;
/* Copy the produced glyphs into IT's glyph_row. */