1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-25 07:28:20 +00:00

Avoid crashes in PGTK build due to signal in 'note_mouse_highlight'

* src/xdisp.c (string_buffer_position): Make sure the TO argument
of 'string_buffer_position_lim' is always inside [BEGV..ZV].
Otherwise 'string_buffer_position_lim' might call
'get-char-property' and friends with invalid position, which will
just signal an error and do nothing useful.  (Bug#60144)
This commit is contained in:
Eli Zaretskii 2022-12-18 10:29:34 +02:00
parent 0fc5fb2d05
commit 660e941235

View File

@ -6281,13 +6281,16 @@ static ptrdiff_t
string_buffer_position (Lisp_Object string, ptrdiff_t around_charpos)
{
const int MAX_DISTANCE = 1000;
ptrdiff_t forward_limit = min (around_charpos + MAX_DISTANCE, ZV);
ptrdiff_t found = string_buffer_position_lim (string, around_charpos,
around_charpos + MAX_DISTANCE,
false);
forward_limit, false);
if (!found)
found = string_buffer_position_lim (string, around_charpos,
around_charpos - MAX_DISTANCE, true);
{
ptrdiff_t backward_limit = max (around_charpos - MAX_DISTANCE, BEGV);
found = string_buffer_position_lim (string, around_charpos,
backward_limit, true);
}
return found;
}