From dc4db3ef09dd5851c48421757a5b5e0f439a143e Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 31 May 2020 17:34:09 +0300 Subject: [PATCH] Protect bidi cache from inadvertent resets * src/xdisp.c (Fline_pixel_height, Fmove_point_visually): Save and restore the bidi cache, to avoid inadvertently resetting it by starting a new iteration through buffer text. This could cause trouble if these functions are called during a redisplay cycle, especially while we were processing RTL text. --- src/xdisp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/xdisp.c b/src/xdisp.c index db0ec683159..ea28395cf55 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1415,6 +1415,7 @@ Value is the height in pixels of the line at point. */) set_buffer_internal_1 (XBUFFER (w->contents)); } SET_TEXT_POS (pt, PT, PT_BYTE); + void *itdata = bidi_shelve_cache (); start_display (&it, w, pt); /* Start from the beginning of the screen line, to make sure we traverse all of its display elements, and thus capture the @@ -1426,6 +1427,7 @@ Value is the height in pixels of the line at point. */) if (old_buffer) set_buffer_internal_1 (old_buffer); + bidi_unshelve_cache (itdata, false); return result; } @@ -24442,6 +24444,7 @@ Value is the new character position of point. */) bool at_eol_p; bool overshoot_expected = false; bool target_is_eol_p = false; + void *itdata = bidi_shelve_cache (); /* Setup the arena. */ SET_TEXT_POS (pt, PT, PT_BYTE); @@ -24670,6 +24673,7 @@ Value is the new character position of point. */) /* Move point to that position. */ SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); + bidi_unshelve_cache (itdata, false); } return make_fixnum (PT); -- 2.39.5