]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.2030: no max callback recursion limit v9.0.2030
authorChristian Brabandt <cb@256bit.org>
Sun, 15 Oct 2023 07:56:16 +0000 (09:56 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 15 Oct 2023 07:56:16 +0000 (09:56 +0200)
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>
runtime/doc/options.txt
src/testdir/test_popupwin.vim
src/userfunc.c
src/version.c

index 502e77ba1fa58ad2c6fe0b9b752554fef200d3e0..492c7da1ee7102dd837bddd4c6891fa4ebb1ba2d 100644 (file)
@@ -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 short description can be found at |Q_op|.
        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)
index 60dc5d9b99a13da3e2dc79dd6fca385935e4079b..a256ddfb2e371cc0883106413d8c360ce65b29e6 100644 (file)
@@ -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
index db16b68049e55f32c633f9ba34a004c2926e1429..a3b8bdc103ec7438c56e9fb99849f5b8096d087a 100644 (file)
@@ -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;
index ec9a07d0740d706646ed16d7f66102e5ad6acbf0..b90f76fc1532e246175394c46c2e7381f0d8acc8 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2030,
 /**/
     2029,
 /**/