summaryrefslogtreecommitdiff
path: root/src/terminal.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-19 21:23:05 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-19 21:23:05 +0200
commit77ac9b5c62b35e90df35fc0bfdee57636cedb144 (patch)
tree5bee7d381bc87441ccd0def5d9d8ed0c98e189cf /src/terminal.c
parent93c92eff26cbf6b1f1a81891ebaf53ee3fb86d51 (diff)
downloadvim-git-77ac9b5c62b35e90df35fc0bfdee57636cedb144.tar.gz
patch 8.0.0968: crash when switching terminal modesv8.0.0968
Problem: Crash when switching terminal modes. (Nikolai Pavlov) Solution: Check that there are scrollback lines.
Diffstat (limited to 'src/terminal.c')
-rw-r--r--src/terminal.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/terminal.c b/src/terminal.c
index 6b401beee..bb2dba90c 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1037,14 +1037,13 @@ term_enter_job_mode()
/* Remove the terminal contents from the scrollback and the buffer. */
gap = &term->tl_scrollback;
- while (curbuf->b_ml.ml_line_count > term->tl_scrollback_scrolled)
+ while (curbuf->b_ml.ml_line_count > term->tl_scrollback_scrolled
+ && gap->ga_len > 0)
{
ml_delete(curbuf->b_ml.ml_line_count, FALSE);
line = (sb_line_T *)gap->ga_data + gap->ga_len - 1;
vim_free(line->sb_cells);
--gap->ga_len;
- if (gap->ga_len == 0)
- break;
}
check_cursor();