0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

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)
This commit is contained in:
zeertzjq
2022-11-01 11:44:43 +00:00
committed by Bram Moolenaar
parent 7a7db047dc
commit 873f41a018
4 changed files with 27 additions and 4 deletions

View File

@@ -889,6 +889,11 @@ f_win_move_separator(typval_T *argvars, typval_T *rettv)
wp = find_win_by_nr_or_id(&argvars[0]); wp = find_win_by_nr_or_id(&argvars[0]);
if (wp == NULL || win_valid_popup(wp)) if (wp == NULL || win_valid_popup(wp))
return; return;
if (!win_valid(wp))
{
emsg(_(e_cannot_resize_window_in_another_tab_page));
return;
}
offset = (int)tv_get_number(&argvars[1]); offset = (int)tv_get_number(&argvars[1]);
win_drag_vsep_line(wp, offset); win_drag_vsep_line(wp, offset);

View File

@@ -1664,6 +1664,12 @@ func Test_mouse_drag_statusline()
" this was causing a crash in win_drag_status_line() " this was causing a crash in win_drag_status_line()
call feedkeys("\<F2>:tabnew\<CR>\<F3>", 'tx') call feedkeys("\<F2>:tabnew\<CR>\<F3>", 'tx')
nunmap <F2>
nunmap <F3>
delfunc ClickExpr
delfunc DragExpr
set laststatus& mouse&
endfunc endfunc
" Test for mapping <LeftDrag> in Insert mode " Test for mapping <LeftDrag> in Insert mode

View File

@@ -1483,23 +1483,33 @@ func Test_win_move_separator()
call assert_equal(w0, winwidth(0)) call assert_equal(w0, winwidth(0))
call assert_true(win_move_separator(0, -1)) call assert_true(win_move_separator(0, -1))
call assert_equal(w0, winwidth(0)) call assert_equal(w0, winwidth(0))
" check that win_move_separator doesn't error with offsets beyond moving " check that win_move_separator doesn't error with offsets beyond moving
" possibility " possibility
call assert_true(win_move_separator(id, 5000)) call assert_true(win_move_separator(id, 5000))
call assert_true(winwidth(id) > w) call assert_true(winwidth(id) > w)
call assert_true(win_move_separator(id, -5000)) call assert_true(win_move_separator(id, -5000))
call assert_true(winwidth(id) < w) call assert_true(winwidth(id) < w)
" check that win_move_separator returns false for an invalid window " check that win_move_separator returns false for an invalid window
wincmd = wincmd =
let w = winwidth(0) let w = winwidth(0)
call assert_false(win_move_separator(-1, 1)) call assert_false(win_move_separator(-1, 1))
call assert_equal(w, winwidth(0)) call assert_equal(w, winwidth(0))
" check that win_move_separator returns false for a popup window " check that win_move_separator returns false for a popup window
let id = popup_create(['hello', 'world'], {}) let id = popup_create(['hello', 'world'], {})
let w = winwidth(id) let w = winwidth(id)
call assert_false(win_move_separator(id, 1)) call assert_false(win_move_separator(id, 1))
call assert_equal(w, winwidth(id)) call assert_equal(w, winwidth(id))
call popup_close(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! %bwipe!
endfunc endfunc

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
824,
/**/ /**/
823, 823,
/**/ /**/