# HG changeset patch # User Bram Moolenaar # Date 1667384334 -3600 # Node ID 1b194361b71aabbe9856515e6f736f8a4509632a # Parent 2b296efc02cf177f9f899435b0e18f96b11b2b48 patch 9.0.0824: crash when using win_move_separator() in other tab page Commit: https://github.com/vim/vim/commit/873f41a0187e81a22aa4622fbf938de72a54abba Author: zeertzjq Date: Tue Nov 1 11:44:43 2022 +0000 patch 9.0.0824: crash when using win_move_separator() in other tab page Problem: Crash when using win_move_separator() in other tab page. Solution: Check for valid window in current tab page. (closes #11479, closes #11427) diff --git a/src/evalwindow.c b/src/evalwindow.c --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -889,6 +889,11 @@ f_win_move_separator(typval_T *argvars, wp = find_win_by_nr_or_id(&argvars[0]); if (wp == NULL || win_valid_popup(wp)) return; + if (!win_valid(wp)) + { + emsg(_(e_cannot_resize_window_in_another_tab_page)); + return; + } offset = (int)tv_get_number(&argvars[1]); win_drag_vsep_line(wp, offset); diff --git a/src/testdir/test_mapping.vim b/src/testdir/test_mapping.vim --- a/src/testdir/test_mapping.vim +++ b/src/testdir/test_mapping.vim @@ -1652,18 +1652,24 @@ func Test_mouse_drag_statusline() set laststatus=2 set mouse=a func ClickExpr() - call test_setmouse(&lines - 1, 1) - return "\" + call test_setmouse(&lines - 1, 1) + return "\" endfunc func DragExpr() - call test_setmouse(&lines - 2, 1) - return "\" + call test_setmouse(&lines - 2, 1) + return "\" endfunc nnoremap ClickExpr() nnoremap DragExpr() " this was causing a crash in win_drag_status_line() call feedkeys("\:tabnew\\", 'tx') + + nunmap + nunmap + delfunc ClickExpr + delfunc DragExpr + set laststatus& mouse& endfunc " Test for mapping in Insert mode diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim --- a/src/testdir/test_window_cmd.vim +++ b/src/testdir/test_window_cmd.vim @@ -1483,23 +1483,33 @@ func Test_win_move_separator() call assert_equal(w0, winwidth(0)) call assert_true(win_move_separator(0, -1)) call assert_equal(w0, winwidth(0)) + " check that win_move_separator doesn't error with offsets beyond moving " possibility call assert_true(win_move_separator(id, 5000)) call assert_true(winwidth(id) > w) call assert_true(win_move_separator(id, -5000)) call assert_true(winwidth(id) < w) + " check that win_move_separator returns false for an invalid window wincmd = let w = winwidth(0) call assert_false(win_move_separator(-1, 1)) call assert_equal(w, winwidth(0)) + " check that win_move_separator returns false for a popup window let id = popup_create(['hello', 'world'], {}) let w = winwidth(id) call assert_false(win_move_separator(id, 1)) call assert_equal(w, winwidth(id)) call popup_close(id) + + " check that using another tabpage fails without crash + let id = win_getid() + tabnew + call assert_fails('call win_move_separator(id, -1)', 'E1308:') + tabclose + %bwipe! endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 824, +/**/ 823, /**/ 822,