]> granicus.if.org Git - vim/commitdiff
patch 8.2.0204: crash when using winnr('j') in a popup window v8.2.0204
authorBram Moolenaar <Bram@vim.org>
Mon, 3 Feb 2020 21:15:26 +0000 (22:15 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 3 Feb 2020 21:15:26 +0000 (22:15 +0100)
Problem:    Crash when using winnr('j') in a popup window.
Solution:   Do not search for neighbors in a popup window. (closes #5568)

src/evalwindow.c
src/testdir/test_popupwin.vim
src/version.c
src/window.c

index fb54033e5e925cb9385059f80b1e89dcb4c563ce..be6762a5c6ebf74b3ed8fb16c5577756bc5ca8c4 100644 (file)
@@ -332,8 +332,6 @@ get_winnr(tabpage_T *tp, typval_T *argvar)
        else if (STRCMP(arg, "#") == 0)
        {
            twin = (tp == curtab) ? prevwin : tp->tp_prevwin;
-           if (twin == NULL)
-               nr = 0;
        }
        else
        {
@@ -360,6 +358,8 @@ get_winnr(tabpage_T *tp, typval_T *argvar)
            else
                invalid_arg = TRUE;
        }
+       if (twin == NULL)
+           nr = 0;
 
        if (invalid_arg)
        {
index f8f501afaa9a3b5c0aeefb7f2b3cceb105272717..ad5a8086117d85cd9797dad2919723973657eff2 100644 (file)
@@ -2400,9 +2400,14 @@ func Test_popupwin_terminal_buffer()
 
   let origwin = win_getid()
   let ptybuf = term_start(&shell, #{hidden: 1})
-  let winnr = popup_create(ptybuf, #{minwidth: 40, minheight: 10})
+  let winid = popup_create(ptybuf, #{minwidth: 40, minheight: 10})
   " Wait for shell to start
   sleep 200m
+  " Check this doesn't crash
+  call assert_equal(winnr(), winnr('j'))
+  call assert_equal(winnr(), winnr('k'))
+  call assert_equal(winnr(), winnr('h'))
+  call assert_equal(winnr(), winnr('l'))
   " Cannot quit while job is running
   call assert_fails('call feedkeys("\<C-W>:quit\<CR>", "xt")', 'E948:')
   call feedkeys("exit\<CR>", 'xt')
index 43a03fe497d794a5f65cb554a8d5622de0e510a3..c3dbec81d3ca746ab077771383d5f719f55eca38 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    204,
 /**/
     203,
 /**/
index 23037fe753f3eea41746da96466c1e1c9e1d6e7e..964f1ef6d7aee04b55ba7511d5131d238c607d84 100644 (file)
@@ -4431,6 +4431,11 @@ win_vert_neighbor(tabpage_T *tp, win_T *wp, int up, long count)
     frame_T    *nfr;
     frame_T    *foundfr;
 
+#ifdef FEAT_PROP_POPUP
+    if (popup_is_popup(wp))
+       // popups don't have neighbors.
+       return NULL;
+#endif
     foundfr = wp->w_frame;
     while (count--)
     {
@@ -4513,6 +4518,11 @@ win_horz_neighbor(tabpage_T *tp, win_T *wp, int left, long count)
     frame_T    *nfr;
     frame_T    *foundfr;
 
+#ifdef FEAT_PROP_POPUP
+    if (popup_is_popup(wp))
+       // popups don't have neighbors.
+       return NULL;
+#endif
     foundfr = wp->w_frame;
     while (count--)
     {