Skip to content

Commit d2fad67

Browse files
committed
patch 8.1.1264: crash when closing window from WinBar click
Problem: Crash when closing window from WinBar click. (Ben Jackson) Solution: Check that window pointer is still valid. (closes #4337)
1 parent 66f8311 commit d2fad67

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/menu.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,7 +2488,7 @@ winbar_click(win_T *wp, int col)
24882488

24892489
if (col >= item->wb_startcol && col <= item->wb_endcol)
24902490
{
2491-
win_T *save_curwin = NULL;
2491+
win_T *save_curwin = NULL;
24922492
pos_T save_visual = VIsual;
24932493
int save_visual_active = VIsual_active;
24942494
int save_visual_select = VIsual_select;
@@ -2506,9 +2506,10 @@ winbar_click(win_T *wp, int col)
25062506
check_cursor();
25072507
}
25082508

2509+
// Note: the command might close the current window.
25092510
execute_menu(NULL, item->wb_menu, -1);
25102511

2511-
if (save_curwin != NULL)
2512+
if (save_curwin != NULL && win_valid(save_curwin))
25122513
{
25132514
curwin = save_curwin;
25142515
curbuf = curwin->w_buffer;
@@ -2518,6 +2519,8 @@ winbar_click(win_T *wp, int col)
25182519
VIsual_reselect = save_visual_reselect;
25192520
VIsual_mode = save_visual_mode;
25202521
}
2522+
if (!win_valid(wp))
2523+
break;
25212524
}
25222525
}
25232526
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,8 @@ static char *(features[]) =
767767

768768
static int included_patches[] =
769769
{ /* Add new patch number below this line */
770+
/**/
771+
1264,
770772
/**/
771773
1263,
772774
/**/

0 commit comments

Comments
 (0)