diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-09-25 22:14:48 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-09-25 22:14:48 +0200 |
commit | e0d749a49630778d45642d7589a3703697746760 (patch) | |
tree | 370bd15386bc479491d0aa3f70abeed83038c2ec /src | |
parent | 101e99207f813ca48a4c0787eed9eb8bf67fba5a (diff) | |
download | vim-git-e0d749a49630778d45642d7589a3703697746760.tar.gz |
patch 8.1.2076: crash when trying to put a terminal in a popup windowv8.1.2076
Problem: Crash when trying to put a terminal buffer in a popup window.
Solution: Check for NULL buffer. Do not allow putting a terminal in a popup
window.
Diffstat (limited to 'src')
-rw-r--r-- | src/libvterm/src/termscreen.c | 2 | ||||
-rw-r--r-- | src/popupwin.c | 5 | ||||
-rw-r--r-- | src/terminal.c | 2 | ||||
-rw-r--r-- | src/testdir/test_popupwin.vim | 6 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 17 insertions, 0 deletions
diff --git a/src/libvterm/src/termscreen.c b/src/libvterm/src/termscreen.c index c33fb59b4..6ad0e1afd 100644 --- a/src/libvterm/src/termscreen.c +++ b/src/libvterm/src/termscreen.c @@ -75,6 +75,8 @@ static ScreenCell *getcell(const VTermScreen *screen, int row, int col) return NULL; if(col < 0 || col >= screen->cols) return NULL; + if (screen->buffer == NULL) + return NULL; return screen->buffer + (screen->cols * row) + col; } diff --git a/src/popupwin.c b/src/popupwin.c index 81cc17f2d..5425d09bb 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -1638,6 +1638,11 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type) semsg(_(e_nobufnr), argvars[0].vval.v_number); return NULL; } + if (buf->b_term != NULL) + { + emsg(_("E278: Cannot put a terminal buffer in a popup window")); + return NULL; + } } else if (!(argvars[0].v_type == VAR_STRING && argvars[0].vval.v_string != NULL) diff --git a/src/terminal.c b/src/terminal.c index a8b7881f5..f1d89ab9e 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -3347,6 +3347,8 @@ term_update_window(win_T *wp) newcols = MIN(newcols, twp->w_width); } } + if (newrows == 99999 || newcols == 99999) + return; // safety exit newrows = rows == 0 ? newrows : minsize ? MAX(rows, newrows) : rows; newcols = cols == 0 ? newcols : minsize ? MAX(cols, newcols) : cols; diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 11e554fe7..dfdfc13eb 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -1992,6 +1992,12 @@ func Test_popupwin_with_buffer() call delete('XsomeFile') endfunc +func Test_popupwin_terminal_buffer() + let ptybuf = term_start(&shell, #{hidden: 1}) + call assert_fails('let winnr = popup_create(ptybuf, #{})', 'E278:') + exe 'bwipe! ' .. ptybuf +endfunc + func Test_popupwin_with_buffer_and_filter() new Xwithfilter call setline(1, range(100)) diff --git a/src/version.c b/src/version.c index f1c082bc6..4bf2106f6 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2076, +/**/ 2075, /**/ 2074, |