Mercurial > vim
changeset 33570:28c2f681ec33 v9.0.2030
patch 9.0.2030: no max callback recursion limit
Commit: https://github.com/vim/vim/commit/47510f3d6598a1218958c03ed11337a43b73f48d
Author: Christian Brabandt <cb@256bit.org>
Date: Sun Oct 15 09:56:16 2023 +0200
patch 9.0.2030: no max callback recursion limit
Problem: no max callback recursion limit
Solution: bail out, if max call recursion for callback functions
has been reached.
This checks the 'maxfuncdepth' setting and throws E169 when a callback
function recursively calls itself.
closes: #13337
closes: #13339
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 15 Oct 2023 10:00:06 +0200 |
parents | 9538f4381328 |
children | 93082dd250b6 |
files | runtime/doc/options.txt src/testdir/test_popupwin.vim src/userfunc.c src/version.c |
diffstat | 4 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 9.0. Last change: 2023 Aug 15 +*options.txt* For Vim version 9.0. Last change: 2023 Oct 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -5485,6 +5485,7 @@ A jump table for the options with a shor Increasing this limit above 200 also changes the maximum for Ex command recursion, see |E169|. See also |:function|. + Also used for maximum depth of callback functions. *'maxmapdepth'* *'mmd'* *E223* 'maxmapdepth' 'mmd' number (default 1000)
--- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -4205,5 +4205,11 @@ func Test_popupwin_with_error() call StopVimInTerminal(buf) endfunc +func Test_popup_close_callback_recursive() + " this invokes the callback recursively + let winid = popup_create('something', #{callback: 'popup_close'}) + redraw + call assert_fails('call popup_close(winid)', 'E169') +endfunc " vim: shiftwidth=2 sts=2
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -3583,6 +3583,13 @@ call_callback( if (callback->cb_name == NULL || *callback->cb_name == NUL) return FAIL; + + if (callback_depth > p_mfd) + { + emsg(_(e_command_too_recursive)); + return FAIL; + } + CLEAR_FIELD(funcexe); funcexe.fe_evaluate = TRUE; funcexe.fe_partial = callback->cb_partial;