]> granicus.if.org Git - vim/commitdiff
patch 9.0.0824: crash when using win_move_separator() in other tab page v9.0.0824
authorzeertzjq <zeertzjq@outlook.com>
Tue, 1 Nov 2022 11:44:43 +0000 (11:44 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 1 Nov 2022 11:44:43 +0000 (11:44 +0000)
Problem:    Crash when using win_move_separator() in other tab page.
Solution:   Check for valid window in current tab page.
            (closes #11479, closes #11427)

src/evalwindow.c
src/testdir/test_mapping.vim
src/testdir/test_window_cmd.vim
src/version.c

index 98c7ff3084808b6e5aec80a6dd12a7f6ee72b4cc..bc5925182ea0a7b3a4f271d0d856cf80883c3f5a 100644 (file)
@@ -889,6 +889,11 @@ f_win_move_separator(typval_T *argvars, typval_T *rettv)
     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);
index ce9f932d65a0a96e0d170b0d9196347d2ed52083..f8e5a317f95f1fcc2327f55f046c0cb5269a57cf 100644 (file)
@@ -1652,18 +1652,24 @@ func Test_mouse_drag_statusline()
   set laststatus=2
   set mouse=a
   func ClickExpr()
-      call test_setmouse(&lines - 1, 1)
-        return "\<LeftMouse>"
+    call test_setmouse(&lines - 1, 1)
+    return "\<LeftMouse>"
   endfunc
   func DragExpr()
-      call test_setmouse(&lines - 2, 1)
-        return "\<LeftDrag>"
+    call test_setmouse(&lines - 2, 1)
+    return "\<LeftDrag>"
   endfunc
   nnoremap <expr> <F2> ClickExpr()
   nnoremap <expr> <F3> DragExpr()
 
   " this was causing a crash in win_drag_status_line()
   call feedkeys("\<F2>:tabnew\<CR>\<F3>", 'tx')
+
+  nunmap <F2>
+  nunmap <F3>
+  delfunc ClickExpr
+  delfunc DragExpr
+  set laststatus& mouse&
 endfunc
 
 " Test for mapping <LeftDrag> in Insert mode
index 8a7191340881d29ede01fb9a7699d72354a132cc..0d4c278e6326cc89cc461dc559e03b00841be92a 100644 (file)
@@ -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
 
index 16054b0d8d69fce34cac37c716ec44b377beecd0..5d1a2fb37ac1add18b1e126b2e56a53d06391916 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    824,
 /**/
     823,
 /**/