1
1

text: avoid a crash when a spell-checked line has gotten shorter

When using an external spell checker or formatter, the line with
the cursor might become shorter, which might result in the stored
cursor position being beyond the end-of-line.  So, when restoring
the x position, make sure to limit it to the length of the line.

This fixes https://savannah.gnu.org/bugs/?49923.
Этот коммит содержится в:
Benno Schulenberg 2016-12-24 12:09:47 +01:00
родитель dc18746cbd
Коммит edbc1e5950

Просмотреть файл

@ -3073,6 +3073,8 @@ const char *do_alt_speller(char *tempfile_name)
/* Go back to the old position. */
goto_line_posx(lineno_save, current_x_save);
if (openfile->current_x > strlen(openfile->current->data))
openfile->current_x = strlen(openfile->current->data);
openfile->current_y = current_y_save;
openfile->placewewant = pww_save;
adjust_viewport(STATIONARY);
@ -3545,8 +3547,10 @@ void do_formatter(void)
/* Replace the text of the current buffer with the formatted text. */
replace_buffer(temp);
/* Restore the cursor position, and mark the file as modified. */
/* Restore the cursor position. */
goto_line_posx(lineno_save, current_x_save);
if (openfile->current_x > strlen(openfile->current->data))
openfile->current_x = strlen(openfile->current->data);
openfile->current_y = current_y_save;
openfile->placewewant = pww_save;
adjust_viewport(STATIONARY);