patch 8.2.3902: Vim9: double free with nested :def function
Problem: Vim9: double free with nested :def function.
Solution: Pass "line_to_free" from compile_def_function() and make sure
cmdlinep is valid.
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 5b8ad17..1a14c10 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1669,6 +1669,26 @@
assert_fails('FuncWithForwardCall()', 'E1096:', '', 1, 'FuncWithForwardCall')
enddef
+def Test_nested_functin_with_nextcmd()
+ var lines =<< trim END
+ vim9script
+ # Define an outer function
+ def FirstFunction()
+ # Define an inner function
+ def SecondFunction()
+ # the function has a body, a double free is detected.
+ AAAAA
+
+ # enddef followed by | or } followed by # one or more characters
+ enddef|BBBB
+ enddef
+
+ # Compile all functions
+ defcompile
+ END
+ CheckScriptFailure(lines, 'E476: Invalid command: AAAAA')
+enddef
+
def Test_return_type_wrong()
CheckScriptFailure([
'def Func(): number',