summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Brabandt <cb@256bit.org>2023-10-15 09:56:16 +0200
committerChristian Brabandt <cb@256bit.org>2023-10-15 09:56:16 +0200
commit47510f3d6598a1218958c03ed11337a43b73f48d (patch)
treebbe51bf33ac367ac3a534d8f779d71c1d7e8011f /src
parent1ace49fb98fa93e2fcff421a5f7da1aa41c512ed (diff)
patch 9.0.2030: no max callback recursion limitv9.0.2030
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>
Diffstat (limited to 'src')
-rw-r--r--src/testdir/test_popupwin.vim6
-rw-r--r--src/userfunc.c7
-rw-r--r--src/version.c2
3 files changed, 15 insertions, 0 deletions
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 60dc5d9b99..a256ddfb2e 100644
--- 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
diff --git a/src/userfunc.c b/src/userfunc.c
index db16b68049..a3b8bdc103 100644
--- 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;
diff --git a/src/version.c b/src/version.c
index ec9a07d074..b90f76fc15 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2030,
+/**/
2029,
/**/
2028,