]> granicus.if.org Git - vim/commitdiff
patch 8.0.1485: weird autocmd may cause arglist to be changed recursively v8.0.1485
authorBram Moolenaar <Bram@vim.org>
Fri, 9 Feb 2018 16:50:28 +0000 (17:50 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 9 Feb 2018 16:50:28 +0000 (17:50 +0100)
Problem:    Weird autocmd may cause arglist to be changed recursively.
Solution:   Prevent recursively changing the argument list. (Christian
            Brabandt, closes #2472)

src/ex_docmd.c
src/globals.h
src/version.c

index cd915c9daeaf513581117c3498259e727f80e9d8..591775f4c4c2efaef63c7731873396522e964496 100644 (file)
@@ -8058,6 +8058,16 @@ alist_set(
     int                fnum_len)
 {
     int                i;
+    static int  recursive = 0;
+
+    if (recursive)
+    {
+#ifdef FEAT_AUTOCMD
+       EMSG(_(e_au_recursive));
+#endif
+       return;
+    }
+    ++recursive;
 
     alist_clear(al);
     if (ga_grow(&al->al_ga, count) == OK)
@@ -8087,6 +8097,8 @@ alist_set(
        FreeWild(count, files);
     if (al == &global_alist)
        arg_had_last = FALSE;
+
+    --recursive;
 }
 
 /*
index 737812cdda6f1f58f575d7aa8b0d7f527b124283..943bb3130a830f56b0a589d43a053721adec5942 100644 (file)
@@ -1594,6 +1594,9 @@ EXTERN char_u e_notset[]  INIT(= N_("E764: Option '%s' is not set"));
 EXTERN char_u e_invalidreg[]    INIT(= N_("E850: Invalid register name"));
 #endif
 EXTERN char_u e_dirnotf[]      INIT(= N_("E919: Directory not found in '%s': \"%s\""));
+#ifdef FEAT_AUTOCMD
+EXTERN char_u e_au_recursive[] INIT(= N_("E952: Autocommand caused recursive behavior"));
+#endif
 
 #ifdef FEAT_GUI_MAC
 EXTERN short disallow_gui      INIT(= FALSE);
index f56ef3577427fe367dcdac9000ac06a67044be20..963f611fa5992ccc1ee058511a96f918b6cf093a 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1485,
 /**/
     1484,
 /**/