• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révision5fbb167591fcf0158d77777dd5e323260f6d5027 (tree)
l'heure2019-12-12 03:45:04
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 8.1.2420: crash when calling popup_close() in win_execute()

Commit: https://github.com/vim/vim/commit/4954019c93a2bb5a0b1af54b5961c933beeb56f4
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 11 19:34:54 2019 +0100

patch 8.1.2420: crash when calling popup_close() in win_execute()
Problem: Crash when calling popup_close() in win_execute().
Solution: Disallow popup_close() in popup window. (Yasuhiro Matsumoto,
closes #5345)

Change Summary

Modification

diff -r c9409f359583 -r 5fbb167591fc src/popupwin.c
--- a/src/popupwin.c Wed Dec 11 19:15:05 2019 +0100
+++ b/src/popupwin.c Wed Dec 11 19:45:04 2019 +0100
@@ -1753,7 +1753,7 @@
17531753 // Check that arguments look OK.
17541754 if (argvars[0].v_type == VAR_NUMBER)
17551755 {
1756- buf = buflist_findnr( argvars[0].vval.v_number);
1756+ buf = buflist_findnr(argvars[0].vval.v_number);
17571757 if (buf == NULL)
17581758 {
17591759 semsg(_(e_nobufnr), argvars[0].vval.v_number);
@@ -2097,6 +2097,10 @@
20972097 {
20982098 int id = wp->w_id;
20992099
2100+ // Just in case a check higher up is missing.
2101+ if (wp == curwin && ERROR_IF_POPUP_WINDOW)
2102+ return;
2103+
21002104 if (wp->w_close_cb.cb_name != NULL)
21012105 // Careful: This may make "wp" invalid.
21022106 invoke_popup_callback(wp, arg);
@@ -2331,8 +2335,12 @@
23312335 f_popup_close(typval_T *argvars, typval_T *rettv UNUSED)
23322336 {
23332337 int id = (int)tv_get_number(argvars);
2334- win_T *wp = find_popup_win(id);
2335-
2338+ win_T *wp;
2339+
2340+ if (ERROR_IF_POPUP_WINDOW)
2341+ return;
2342+
2343+ wp = find_popup_win(id);
23362344 if (wp != NULL)
23372345 popup_close_and_callback(wp, &argvars[1]);
23382346 }
diff -r c9409f359583 -r 5fbb167591fc src/testdir/test_popupwin.vim
--- a/src/testdir/test_popupwin.vim Wed Dec 11 19:15:05 2019 +0100
+++ b/src/testdir/test_popupwin.vim Wed Dec 11 19:45:04 2019 +0100
@@ -891,6 +891,10 @@
891891 let winid = popup_create('some text', {})
892892 call assert_fails('call win_execute(winid, winnr() .. "close")', 'E994')
893893 call popup_clear()
894+
895+ let winid = popup_create('some text', {})
896+ call assert_fails('call win_execute(winid, printf("normal! :\<C-u>call popup_close(%d)\<CR>", winid))', 'E994')
897+ call popup_clear()
894898 endfunc
895899
896900 func Test_win_execute_not_allowed()
diff -r c9409f359583 -r 5fbb167591fc src/version.c
--- a/src/version.c Wed Dec 11 19:15:05 2019 +0100
+++ b/src/version.c Wed Dec 11 19:45:04 2019 +0100
@@ -743,6 +743,8 @@
743743 static int included_patches[] =
744744 { /* Add new patch number below this line */
745745 /**/
746+ 2420,
747+/**/
746748 2419,
747749 /**/
748750 2418,
Afficher sur ancien navigateur de dépôt.