diff src/ex_docmd.c @ 13221:dc28351a85d4 v8.0.1485

patch 8.0.1485: weird autocmd may cause arglist to be changed recursively commit https://github.com/vim/vim/commit/9e33efd1523b85a70533930dd43a26925a2b648c Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 9 17:50:28 2018 +0100 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)
author Christian Brabandt <cb@256bit.org>
date Fri, 09 Feb 2018 18:00:07 +0100
parents 6559e98f3e74
children ac42c4b11dbc
line wrap: on
line diff
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -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;
 }
 
 /*