diff options
| author | Eli Zaretskii | 2022-12-18 10:29:34 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2022-12-18 10:29:34 +0200 |
| commit | 660e941235d0e4e8490d53ad06cdb1e5699634fa (patch) | |
| tree | fbada1ae2efc6ee21889fee1f54e11c8b8482d1b /src | |
| parent | 0fc5fb2d054c2de17a3c2a3db9110312fa366cf9 (diff) | |
| download | emacs-660e941235d0e4e8490d53ad06cdb1e5699634fa.tar.gz emacs-660e941235d0e4e8490d53ad06cdb1e5699634fa.zip | |
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)
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 45da4966907..06c8b7730cd 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -6281,13 +6281,16 @@ static ptrdiff_t | |||
| 6281 | string_buffer_position (Lisp_Object string, ptrdiff_t around_charpos) | 6281 | string_buffer_position (Lisp_Object string, ptrdiff_t around_charpos) |
| 6282 | { | 6282 | { |
| 6283 | const int MAX_DISTANCE = 1000; | 6283 | const int MAX_DISTANCE = 1000; |
| 6284 | ptrdiff_t forward_limit = min (around_charpos + MAX_DISTANCE, ZV); | ||
| 6284 | ptrdiff_t found = string_buffer_position_lim (string, around_charpos, | 6285 | ptrdiff_t found = string_buffer_position_lim (string, around_charpos, |
| 6285 | around_charpos + MAX_DISTANCE, | 6286 | forward_limit, false); |
| 6286 | false); | ||
| 6287 | 6287 | ||
| 6288 | if (!found) | 6288 | if (!found) |
| 6289 | found = string_buffer_position_lim (string, around_charpos, | 6289 | { |
| 6290 | around_charpos - MAX_DISTANCE, true); | 6290 | ptrdiff_t backward_limit = max (around_charpos - MAX_DISTANCE, BEGV); |
| 6291 | found = string_buffer_position_lim (string, around_charpos, | ||
| 6292 | backward_limit, true); | ||
| 6293 | } | ||
| 6291 | return found; | 6294 | return found; |
| 6292 | } | 6295 | } |
| 6293 | 6296 | ||