]> granicus.if.org Git - vim/commitdiff
patch 8.2.2414: using freed memory when closing the cmdline window v8.2.2414
authorBram Moolenaar <Bram@vim.org>
Tue, 26 Jan 2021 21:00:52 +0000 (22:00 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 26 Jan 2021 21:00:52 +0000 (22:00 +0100)
Problem:    Using freed memory when closing the cmdline window.
Solution:   Check the window is still valid.

src/ex_getln.c
src/version.c

index 5430014765f41c0d3f378a99498740d4ebeef601..d025368218a29623dd4bdf69a15eccc75796beb5 100644 (file)
@@ -4395,10 +4395,15 @@ open_cmdwin(void)
        // Avoid command-line window first character being concealed.
        curwin->w_p_cole = 0;
 # endif
+       // First go back to the original window.
        wp = curwin;
        set_bufref(&bufref, curbuf);
        win_goto(old_curwin);
-       win_close(wp, TRUE);
+
+       // win_goto() may trigger an autocommand that already closes the
+       // cmdline window.
+       if (win_valid(wp))
+           win_close(wp, TRUE);
 
        // win_close() may have already wiped the buffer when 'bh' is
        // set to 'wipe'
index c95b106bb53d5a3084caca46364fa8a63d058515..071a36e8613b95ede0297e9a0013e98dc6011b6d 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2414,
 /**/
     2413,
 /**/