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:
parent
0fc5fb2d05
commit
660e941235
1 changed files with 7 additions and 4 deletions
11
src/xdisp.c
11
src/xdisp.c
|
@ -6281,13 +6281,16 @@ static ptrdiff_t
|
||||||
string_buffer_position (Lisp_Object string, ptrdiff_t around_charpos)
|
string_buffer_position (Lisp_Object string, ptrdiff_t around_charpos)
|
||||||
{
|
{
|
||||||
const int MAX_DISTANCE = 1000;
|
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,
|
ptrdiff_t found = string_buffer_position_lim (string, around_charpos,
|
||||||
around_charpos + MAX_DISTANCE,
|
forward_limit, false);
|
||||||
false);
|
|
||||||
|
|
||||||
if (!found)
|
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;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue