diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-01-02 15:26:27 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-01-02 15:26:27 +0100 |
commit | 777b30f827bcbe10a40640b1bf0361cb93a16be1 (patch) | |
tree | 73dc6a7c70a6d3a79e74817c92d0d5d302982dc9 | |
parent | 54b2bfa399017ebae76ed62f21578261d1b55c1f (diff) |
patch 8.0.0137v8.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'.
-rw-r--r-- | src/ex_docmd.c | 5 | ||||
-rw-r--r-- | src/testdir/test_nested_function.vim | 21 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 26 insertions, 2 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 1af60abd28..eebdcffb48 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -787,8 +787,9 @@ do_cmdline( #endif /* It's possible to create an endless loop with ":execute", catch that - * here. The value of 200 allows nested function calls, ":source", etc. */ - if (call_depth == 200) + * here. The value of 200 allows nested function calls, ":source", etc. + * Allow 200 or 'maxfuncdepth', whatever is larger. */ + if (call_depth >= 200 && call_depth >= p_mfd) { EMSG(_("E169: Command too recursive")); #ifdef FEAT_EVAL diff --git a/src/testdir/test_nested_function.vim b/src/testdir/test_nested_function.vim index 7e301ed33e..afaaea6ceb 100644 --- a/src/testdir/test_nested_function.vim +++ b/src/testdir/test_nested_function.vim @@ -40,3 +40,24 @@ func Test_nested_argument() delfunc g:X unlet g:Y endfunc + +func Recurse(count) + if a:count > 0 + call Recurse(a:count - 1) + endif +endfunc + +func Test_max_nesting() + let call_depth_here = 2 + let ex_depth_here = 5 + set mfd& + + call Recurse(99 - call_depth_here) + call assert_fails('call Recurse(' . (100 - call_depth_here) . ')', 'E132:') + + set mfd=210 + call Recurse(209 - ex_depth_here) + call assert_fails('call Recurse(' . (210 - ex_depth_here) . ')', 'E169:') + + set mfd& +endfunc diff --git a/src/version.c b/src/version.c index f4f20fa261..4a2b3c7204 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 137, +/**/ 136, /**/ 135, |