aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-11-01 07:29:55 +0800
committerGitHub <noreply@github.com>2022-11-01 07:29:55 +0800
commitd8dbf58b4372d1415e3ca69541fc6fe71890ba53 (patch)
treec8340d05ad2763d01bf5102e199ea690bdde91db /src
parent428ab6f24e6b5bae60a71138d571d57ac18528d5 (diff)
downloadrneovim-d8dbf58b4372d1415e3ca69541fc6fe71890ba53.tar.gz
rneovim-d8dbf58b4372d1415e3ca69541fc6fe71890ba53.tar.bz2
rneovim-d8dbf58b4372d1415e3ca69541fc6fe71890ba53.zip
vim-patch:9.0.0821: crash with win_move_statusline() in another tabpage (#20894)
vim-patch:86e6717ace4f Problem: Crash when using win_move_statusline() in another tab page. Solution: Check for valid window pointer. (issue vim/vim#11427) https://github.com/vim/vim/commit/86e6717ace4f5e00eaeb84b59e3fc92bca548155 Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval/funcs.c6
-rw-r--r--src/nvim/testdir/test_window_cmd.vim10
2 files changed, 16 insertions, 0 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index e08dc2e4a5..17781cf4ef 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -112,6 +112,8 @@ PRAGMA_DIAG_POP
static char *e_listblobarg = N_("E899: Argument of %s must be a List or Blob");
static char *e_invalwindow = N_("E957: Invalid window number");
static char *e_reduceempty = N_("E998: Reduce of an empty %s with no initial value");
+static char e_cannot_resize_window_in_another_tab_page[]
+ = N_("E1308: Cannot resize a window in another tab page");
/// Dummy va_list for passing to vim_snprintf
///
@@ -9694,6 +9696,10 @@ static void f_win_move_statusline(typval_T *argvars, typval_T *rettv, EvalFuncDa
if (wp == NULL || wp->w_floating) {
return;
}
+ if (!win_valid(wp)) {
+ emsg(_(e_cannot_resize_window_in_another_tab_page));
+ return;
+ }
offset = (int)tv_get_number(&argvars[1]);
win_drag_status_line(wp, offset);
diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim
index e01993b99c..902a3791d4 100644
--- a/src/nvim/testdir/test_window_cmd.vim
+++ b/src/nvim/testdir/test_window_cmd.vim
@@ -1459,17 +1459,20 @@ func Test_win_move_statusline()
call assert_true(id->win_move_statusline(-offset))
call assert_equal(h, winheight(id))
endfor
+
" check that win_move_statusline doesn't error with offsets beyond moving
" possibility
call assert_true(win_move_statusline(id, 5000))
call assert_true(winheight(id) > h)
call assert_true(win_move_statusline(id, -5000))
call assert_true(winheight(id) < h)
+
" check that win_move_statusline returns false for an invalid window
wincmd =
let h = winheight(0)
call assert_false(win_move_statusline(-1, 1))
call assert_equal(h, winheight(0))
+
" check that win_move_statusline returns false for a floating window
let id = nvim_open_win(
\ 0, 0, #{relative: 'editor', row: 2, col: 2, width: 5, height: 3})
@@ -1477,6 +1480,13 @@ func Test_win_move_statusline()
call assert_false(win_move_statusline(id, 1))
call assert_equal(h, winheight(id))
call nvim_win_close(id, 1)
+
+ " check that using another tabpage fails without crash
+ let id = win_getid()
+ tabnew
+ call assert_fails('call win_move_statusline(id, -1)', 'E1308:')
+ tabclose
+
%bwipe!
endfunc