changeset 19155:013f20a3bc6b v8.2.0137

patch 8.2.0137: crash when using win_execute() from a new tab Commit: https://github.com/vim/vim/commit/a44b3eeafa57d4904a3de86b132008b93404f0fd Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 20 21:44:31 2020 +0100 patch 8.2.0137: crash when using win_execute() from a new tab Problem: Crash when using win_execute() from a new tab. Solution: Set the tp_*win pointers. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/5512)
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 Jan 2020 21:45:04 +0100
parents d5a6e9fb73b6
children 5ad73bc6f845
files src/testdir/test_winbuf_close.vim src/version.c src/window.c
diffstat 3 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_winbuf_close.vim
+++ b/src/testdir/test_winbuf_close.vim
@@ -160,7 +160,7 @@ func Test_winfixwidth_on_close()
 endfunction
 
 " Test that 'winfixheight' will be respected even there is non-leaf frame
-fun! Test_winfixheight_non_leaf_frame()
+func Test_winfixheight_non_leaf_frame()
   vsplit
   botright 11new
   let l:wid = win_getid()
@@ -173,7 +173,7 @@ fun! Test_winfixheight_non_leaf_frame()
 endf
 
 " Test that 'winfixwidth' will be respected even there is non-leaf frame
-fun! Test_winfixwidth_non_leaf_frame()
+func Test_winfixwidth_non_leaf_frame()
   split
   topleft 11vnew
   let l:wid = win_getid()
@@ -184,3 +184,13 @@ fun! Test_winfixwidth_non_leaf_frame()
   call assert_equal(11, winwidth(l:wid))
   %bwipe!
 endf
+
+func Test_tabwin_close()
+  enew
+  let l:wid = win_getid()
+  tabedit
+  call win_execute(l:wid, 'close')
+  " Should not crash.
+  call assert_true(v:true)
+  %bwipe!
+endfunc
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    137,
+/**/
     136,
 /**/
     135,
--- a/src/window.c
+++ b/src/window.c
@@ -3616,6 +3616,9 @@ win_alloc_first(void)
 	return FAIL;
     first_tabpage->tp_topframe = topframe;
     curtab = first_tabpage;
+    curtab->tp_firstwin = firstwin;
+    curtab->tp_lastwin = lastwin;
+    curtab->tp_curwin = curwin;
 
     return OK;
 }
@@ -3854,6 +3857,8 @@ win_new_tabpage(int after)
 	    newtp->tp_next = tp->tp_next;
 	    tp->tp_next = newtp;
 	}
+	newtp->tp_firstwin = newtp->tp_lastwin = newtp->tp_curwin = curwin;
+
 	win_init_size();
 	firstwin->w_winrow = tabline_height();
 	win_comp_scroll(curwin);