Skip to content

Commit 9e33efd

Browse files
committed
patch 8.0.1485: weird autocmd may cause arglist to be changed recursively
Problem: Weird autocmd may cause arglist to be changed recursively. Solution: Prevent recursively changing the argument list. (Christian Brabandt, closes #2472)
1 parent a15ef45 commit 9e33efd

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/ex_docmd.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8058,6 +8058,16 @@ alist_set(
80588058
int fnum_len)
80598059
{
80608060
int i;
8061+
static int recursive = 0;
8062+
8063+
if (recursive)
8064+
{
8065+
#ifdef FEAT_AUTOCMD
8066+
EMSG(_(e_au_recursive));
8067+
#endif
8068+
return;
8069+
}
8070+
++recursive;
80618071

80628072
alist_clear(al);
80638073
if (ga_grow(&al->al_ga, count) == OK)
@@ -8087,6 +8097,8 @@ alist_set(
80878097
FreeWild(count, files);
80888098
if (al == &global_alist)
80898099
arg_had_last = FALSE;
8100+
8101+
--recursive;
80908102
}
80918103

80928104
/*

src/globals.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,9 @@ EXTERN char_u e_notset[] INIT(= N_("E764: Option '%s' is not set"));
15941594
EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name"));
15951595
#endif
15961596
EXTERN char_u e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\""));
1597+
#ifdef FEAT_AUTOCMD
1598+
EXTERN char_u e_au_recursive[] INIT(= N_("E952: Autocommand caused recursive behavior"));
1599+
#endif
15971600

15981601
#ifdef FEAT_GUI_MAC
15991602
EXTERN short disallow_gui INIT(= FALSE);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1485,
774776
/**/
775777
1484,
776778
/**/

0 commit comments

Comments
 (0)