]> granicus.if.org Git - vim/commitdiff
patch 8.1.1264: crash when closing window from WinBar click v8.1.1264
authorBram Moolenaar <Bram@vim.org>
Sat, 4 May 2019 14:55:25 +0000 (16:55 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 4 May 2019 14:55:25 +0000 (16:55 +0200)
Problem:    Crash when closing window from WinBar click. (Ben Jackson)
Solution:   Check that window pointer is still valid. (closes #4337)

src/menu.c
src/version.c

index da03322bfd1fceba14d1ca2d576a94471cf21dab..21d3e11766aa6073d18fa4beef7194304969679e 100644 (file)
@@ -2488,7 +2488,7 @@ winbar_click(win_T *wp, int col)
 
        if (col >= item->wb_startcol && col <= item->wb_endcol)
        {
-           win_T *save_curwin = NULL;
+           win_T   *save_curwin = NULL;
            pos_T   save_visual = VIsual;
            int     save_visual_active = VIsual_active;
            int     save_visual_select = VIsual_select;
@@ -2506,9 +2506,10 @@ winbar_click(win_T *wp, int col)
                check_cursor();
            }
 
+           // Note: the command might close the current window.
            execute_menu(NULL, item->wb_menu, -1);
 
-           if (save_curwin != NULL)
+           if (save_curwin != NULL && win_valid(save_curwin))
            {
                curwin = save_curwin;
                curbuf = curwin->w_buffer;
@@ -2518,6 +2519,8 @@ winbar_click(win_T *wp, int col)
                VIsual_reselect = save_visual_reselect;
                VIsual_mode = save_visual_mode;
            }
+           if (!win_valid(wp))
+               break;
        }
     }
 }
index f5faef3135d9247d453de9292654f07a0cde4540..f2abf24005c6b06c2c0633d166ca6b5b4aa5dfe7 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1264,
 /**/
     1263,
 /**/