Skip to content

Commit 47510f3

Browse files
committed
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 <[email protected]>
1 parent 1ace49f commit 47510f3

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

runtime/doc/options.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*options.txt* For Vim version 9.0. Last change: 2023 Aug 15
1+
*options.txt* For Vim version 9.0. Last change: 2023 Oct 14
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -5485,6 +5485,7 @@ A jump table for the options with a short description can be found at |Q_op|.
54855485
Increasing this limit above 200 also changes the maximum for Ex
54865486
command recursion, see |E169|.
54875487
See also |:function|.
5488+
Also used for maximum depth of callback functions.
54885489

54895490
*'maxmapdepth'* *'mmd'* *E223*
54905491
'maxmapdepth' 'mmd' number (default 1000)

src/testdir/test_popupwin.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4205,5 +4205,11 @@ func Test_popupwin_with_error()
42054205
call StopVimInTerminal(buf)
42064206
endfunc
42074207

4208+
func Test_popup_close_callback_recursive()
4209+
" this invokes the callback recursively
4210+
let winid = popup_create('something', #{callback: 'popup_close'})
4211+
redraw
4212+
call assert_fails('call popup_close(winid)', 'E169')
4213+
endfunc
42084214

42094215
" vim: shiftwidth=2 sts=2

src/userfunc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3583,6 +3583,13 @@ call_callback(
35833583

35843584
if (callback->cb_name == NULL || *callback->cb_name == NUL)
35853585
return FAIL;
3586+
3587+
if (callback_depth > p_mfd)
3588+
{
3589+
emsg(_(e_command_too_recursive));
3590+
return FAIL;
3591+
}
3592+
35863593
CLEAR_FIELD(funcexe);
35873594
funcexe.fe_evaluate = TRUE;
35883595
funcexe.fe_partial = callback->cb_partial;

src/version.c

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

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
2030,
707709
/**/
708710
2029,
709711
/**/

0 commit comments

Comments
 (0)