mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 14:58:18 +00:00
vim-patch:8.2.0422: crash when passing popup window to win_splitmove()
Problem: Crash when passing popup window to win_splitmove(). (john Devin)
Solution: Disallow moving a popup window. (closes vim/vim#5816)
0f1563ffee
Add translated test for 8.2.0422 (popup->floating)
This commit is contained in:
@@ -4032,7 +4032,8 @@ static void f_win_splitmove(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
targetwin = find_win_by_nr_or_id(&argvars[1]);
|
targetwin = find_win_by_nr_or_id(&argvars[1]);
|
||||||
|
|
||||||
if (wp == NULL || targetwin == NULL || wp == targetwin
|
if (wp == NULL || targetwin == NULL || wp == targetwin
|
||||||
|| !win_valid(wp) || !win_valid(targetwin)) {
|
|| !win_valid(wp) || !win_valid(targetwin)
|
||||||
|
|| win_valid_floating(wp) || win_valid_floating(targetwin)) {
|
||||||
EMSG(_(e_invalwindow));
|
EMSG(_(e_invalwindow));
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
return;
|
return;
|
||||||
|
@@ -845,6 +845,18 @@ func Test_win_splitmove()
|
|||||||
tabclose
|
tabclose
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_floatwin_splitmove()
|
||||||
|
vsplit
|
||||||
|
let win2 = win_getid()
|
||||||
|
let popup_winid = nvim_open_win(0, 0, {'relative': 'win',
|
||||||
|
\ 'row': 3, 'col': 3, 'width': 12, 'height': 3})
|
||||||
|
call assert_fails('call win_splitmove(popup_winid, win2)', 'E957:')
|
||||||
|
call assert_fails('call win_splitmove(win2, popup_winid)', 'E957:')
|
||||||
|
|
||||||
|
call nvim_win_close(popup_winid, 1)
|
||||||
|
bwipe
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_window_resize()
|
func Test_window_resize()
|
||||||
" Vertical :resize (absolute, relative, min and max size).
|
" Vertical :resize (absolute, relative, min and max size).
|
||||||
vsplit
|
vsplit
|
||||||
|
@@ -1619,6 +1619,23 @@ static void win_init_some(win_T *newp, win_T *oldp)
|
|||||||
win_copy_options(oldp, newp);
|
win_copy_options(oldp, newp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return TRUE if "win" is floating window in the current tab page.
|
||||||
|
///
|
||||||
|
/// @param win window to check
|
||||||
|
bool win_valid_floating(const win_T *win)
|
||||||
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
|
{
|
||||||
|
if (win == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||||
|
if (wp == win) {
|
||||||
|
return wp->w_floating;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// Check if "win" is a pointer to an existing window in the current tabpage.
|
/// Check if "win" is a pointer to an existing window in the current tabpage.
|
||||||
///
|
///
|
||||||
|
Reference in New Issue
Block a user