From 94e7f30dbbbed8acfd9412ff864f8cd26712b00d Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 26 Apr 2020 19:17:24 -0400 Subject: 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) https://github.com/vim/vim/commit/d2fad67e3eb71f48d23f283ef8e7b7ddf4ee180f --- src/nvim/menu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 9d37035247..b060464383 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -28,6 +28,7 @@ #include "nvim/ui.h" #include "nvim/eval/typval.h" #include "nvim/screen.h" +#include "nvim/window.h" #define MENUDEPTH 10 /* maximum depth of menus */ @@ -1567,9 +1568,10 @@ void winbar_click(win_T *wp, int col) check_cursor(); } + // Note: the command might close the current window. execute_menu(NULL, item->wb_menu); - if (save_curwin != NULL) { + if (save_curwin != NULL && win_valid(save_curwin)) { curwin = save_curwin; curbuf = curwin->w_buffer; VIsual = save_visual; @@ -1578,6 +1580,9 @@ void winbar_click(win_T *wp, int col) VIsual_reselect = save_visual_reselect; VIsual_mode = save_visual_mode; } + if (!win_valid(wp)) { + break; + } } } } -- cgit