From ee8606d31f01eed4a3e8efb6d8279fb5b4d2845e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 26 Jul 2022 07:46:19 +0800 Subject: vim-patch:8.1.1424: crash when popup menu is deleted while waiting for char Problem: Crash when popup menu is deleted while waiting for char. Solution: Bail out when pum_array was cleared. https://github.com/vim/vim/commit/5c3fb04623d0260762f1c3c1ba250a407098ff2a --- src/nvim/popupmnu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index 5b1b80935e..fce67437c7 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -1054,7 +1054,10 @@ void pum_show_popupmenu(vimmenu_T *menu) ui_flush(); int c = vgetc(); - if (c == ESC || c == Ctrl_C) { + + // Bail out when typing Esc, CTRL-C or some callback closed the popup + // menu. + if (c == ESC || c == Ctrl_C || pum_array == NULL) { break; } else if (c == CAR || c == NL) { // enter: select current item, if any, and close -- cgit From 27116a015981926f9f7a7600fe8cb7b849290082 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 26 Jul 2022 19:36:36 +0800 Subject: vim-patch:9.0.0076: no test for what patch 8.1.1424 fixes Problem: No test for what patch 8.1.1424 fixes. Solution: Add a test. (closes vim/vim#10789) https://github.com/vim/vim/commit/92a1678d488b7d023ddf2cd493a6ee0d7fcf1928 --- src/nvim/popupmnu.c | 4 ++-- src/nvim/testdir/test_popup.vim | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index fce67437c7..746429e5d5 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -1055,8 +1055,8 @@ void pum_show_popupmenu(vimmenu_T *menu) int c = vgetc(); - // Bail out when typing Esc, CTRL-C or some callback closed the popup - // menu. + // Bail out when typing Esc, CTRL-C or some callback or mapping + // closed the popup menu. if (c == ESC || c == Ctrl_C || pum_array == NULL) { break; } else if (c == CAR || c == NL) { diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index a5e4be49f4..0486ed83ad 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -955,6 +955,25 @@ func Test_menu_only_exists_in_terminal() endtry endfunc +" This used to crash before patch 8.1.1424 +func Test_popup_delete_when_shown() + CheckFeature menu + CheckNotGui + + func Func() + popup Foo + return "\" + endfunc + + nmenu Foo.Bar : + nnoremap Func() + call feedkeys("\\\", 'xt') + + delfunc Func + nunmenu Foo.Bar + nunmap +endfunc + func Test_popup_complete_info_01() new inoremap =complete_info().mode -- cgit