vim-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 vim/vim#4337)
d2fad67e3e
This commit is contained in:
Jan Edmund Lazo
2020-04-26 19:17:24 -04:00
parent 5b3ec39df3
commit 94e7f30dbb

View File

@@ -28,6 +28,7 @@
#include "nvim/ui.h" #include "nvim/ui.h"
#include "nvim/eval/typval.h" #include "nvim/eval/typval.h"
#include "nvim/screen.h" #include "nvim/screen.h"
#include "nvim/window.h"
#define MENUDEPTH 10 /* maximum depth of menus */ #define MENUDEPTH 10 /* maximum depth of menus */
@@ -1567,9 +1568,10 @@ void winbar_click(win_T *wp, int col)
check_cursor(); check_cursor();
} }
// Note: the command might close the current window.
execute_menu(NULL, item->wb_menu); execute_menu(NULL, item->wb_menu);
if (save_curwin != NULL) { if (save_curwin != NULL && win_valid(save_curwin)) {
curwin = save_curwin; curwin = save_curwin;
curbuf = curwin->w_buffer; curbuf = curwin->w_buffer;
VIsual = save_visual; VIsual = save_visual;
@@ -1578,6 +1580,9 @@ void winbar_click(win_T *wp, int col)
VIsual_reselect = save_visual_reselect; VIsual_reselect = save_visual_reselect;
VIsual_mode = save_visual_mode; VIsual_mode = save_visual_mode;
} }
if (!win_valid(wp)) {
break;
}
} }
} }
} }