Skip to content

Commit 777b30f

Browse files
committed
patch 8.0.0137
Problem: When 'maxfuncdepth' is set above 200 the nesting is limited to 200. (Brett Stahlman) Solution: Allow for Ex command recursion depending on 'maxfuncdepth'.
1 parent 54b2bfa commit 777b30f

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/ex_docmd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,9 @@ do_cmdline(
787787
#endif
788788

789789
/* It's possible to create an endless loop with ":execute", catch that
790-
* here. The value of 200 allows nested function calls, ":source", etc. */
791-
if (call_depth == 200)
790+
* here. The value of 200 allows nested function calls, ":source", etc.
791+
* Allow 200 or 'maxfuncdepth', whatever is larger. */
792+
if (call_depth >= 200 && call_depth >= p_mfd)
792793
{
793794
EMSG(_("E169: Command too recursive"));
794795
#ifdef FEAT_EVAL

src/testdir/test_nested_function.vim

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,24 @@ func Test_nested_argument()
4040
delfunc g:X
4141
unlet g:Y
4242
endfunc
43+
44+
func Recurse(count)
45+
if a:count > 0
46+
call Recurse(a:count - 1)
47+
endif
48+
endfunc
49+
50+
func Test_max_nesting()
51+
let call_depth_here = 2
52+
let ex_depth_here = 5
53+
set mfd&
54+
55+
call Recurse(99 - call_depth_here)
56+
call assert_fails('call Recurse(' . (100 - call_depth_here) . ')', 'E132:')
57+
58+
set mfd=210
59+
call Recurse(209 - ex_depth_here)
60+
call assert_fails('call Recurse(' . (210 - ex_depth_here) . ')', 'E169:')
61+
62+
set mfd&
63+
endfunc

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
137,
767769
/**/
768770
136,
769771
/**/

0 commit comments

Comments
 (0)