diff options
| author | Eli Zaretskii | 2020-07-07 17:08:19 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2020-07-07 17:08:19 +0300 |
| commit | 71fc003860043487534379ceeaa61ac4a7617756 (patch) | |
| tree | b109a5c3a087ba67d92cb753bbcdea9a89f878b8 /src | |
| parent | 247dcb4b1b1b4ea3d50b63d41c4efa58743f610d (diff) | |
| download | emacs-71fc003860043487534379ceeaa61ac4a7617756.tar.gz emacs-71fc003860043487534379ceeaa61ac4a7617756.zip | |
Avoid infloop in 'format-mode-line'
* src/xdisp.c (decode_mode_spec): Don't use W->start if it is
outside of the buffer's accessible region. (Bug#42220)
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 269777a5b15..bc82d0acc0d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -26342,6 +26342,22 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 26342 | startpos = marker_position (w->start); | 26342 | startpos = marker_position (w->start); |
| 26343 | startpos_byte = marker_byte_position (w->start); | 26343 | startpos_byte = marker_byte_position (w->start); |
| 26344 | height = WINDOW_TOTAL_LINES (w); | 26344 | height = WINDOW_TOTAL_LINES (w); |
| 26345 | /* We cannot cope with w->start being outside of the | ||
| 26346 | accessible portion of the buffer; in particular, | ||
| 26347 | display_count_lines call below will infloop if called with | ||
| 26348 | startpos_byte outside of the [BEGV_BYTE..ZV_BYTE] region. | ||
| 26349 | Such w->start means we were called in some "creative" way | ||
| 26350 | when the buffer's restriction was changed, but the window | ||
| 26351 | wasn't yet redisplayed after that. If that happens, we | ||
| 26352 | need to determine a new base line. */ | ||
| 26353 | if (!(BUF_BEGV_BYTE (b) <= startpos_byte | ||
| 26354 | && startpos_byte <= BUF_ZV_BYTE (b))) | ||
| 26355 | { | ||
| 26356 | startpos = BUF_BEGV (b); | ||
| 26357 | startpos_byte = BUF_BEGV_BYTE (b); | ||
| 26358 | w->base_line_pos = 0; | ||
| 26359 | w->base_line_number = 0; | ||
| 26360 | } | ||
| 26345 | 26361 | ||
| 26346 | /* If we decided that this buffer isn't suitable for line numbers, | 26362 | /* If we decided that this buffer isn't suitable for line numbers, |
| 26347 | don't forget that too fast. */ | 26363 | don't forget that too fast. */ |