]> granicus.if.org Git - vim/commitdiff
patch 8.2.2413: crash when using :all while using a cmdline window v8.2.2413
authorBram Moolenaar <Bram@vim.org>
Tue, 26 Jan 2021 20:35:08 +0000 (21:35 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 26 Jan 2021 20:35:08 +0000 (21:35 +0100)
Problem:    Crash when using :all while using a cmdline window. (Zdenek Dohnal)
Solution:   Disallow :all from the cmdline window.

src/arglist.c
src/ex_getln.c
src/testdir/test_arglist.vim
src/version.c

index 4e971fd4bb36442947b4fc1321a6377966f069ad..06d94280b0d3dfdd0ad69fc74d15dc28f1d1d303 100644 (file)
@@ -884,6 +884,13 @@ do_arg_all(
     win_T      *new_curwin = NULL;
     tabpage_T  *new_curtab = NULL;
 
+#ifdef FEAT_CMDWIN
+    if (cmdwin_type != 0)
+    {
+       emsg(_(e_cmdwin));
+       return;
+    }
+#endif
     if (ARGCOUNT <= 0)
     {
        // Don't give an error message.  We don't want it when the ":all"
index a3e1f4995cf6c97572acc120ec25026bc39232d1..5430014765f41c0d3f378a99498740d4ebeef601 100644 (file)
@@ -4205,6 +4205,9 @@ open_cmdwin(void)
     // Don't let quitting the More prompt make this fail.
     got_int = FALSE;
 
+    // Set "cmdwin_type" before any autocommands may mess things up.
+    cmdwin_type = get_cmdline_type();
+
     // Create the command-line buffer empty.
     if (do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL) == FAIL)
     {
@@ -4213,7 +4216,6 @@ open_cmdwin(void)
        ga_clear(&winsizes);
        return Ctrl_C;
     }
-    cmdwin_type = get_cmdline_type();
 
     apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf);
     (void)setfname(curbuf, (char_u *)"[Command Line]", NULL, TRUE);
index d6c369f0b02647c361a2dda570a5bc27e7a9eab7..b72fe2d5349acda600c17f870590fae6a6c8e016 100644 (file)
@@ -559,4 +559,12 @@ func Test_quit_with_arglist()
   call delete('.c.swp')
 endfunc
 
+" Test for ":all" not working when in the cmdline window
+func Test_all_not_allowed_from_cmdwin()
+  au BufEnter * all
+  next x
+  call assert_fails(":norm 7q?x\<CR>", 'E11:')
+  au! BufEnter
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 9a67633385f276025c50f3f852cdc964aaa1e4b0..c95b106bb53d5a3084caca46364fa8a63d058515 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2413,
 /**/
     2412,
 /**/