Patch 8.2.3923
Problem:    Vim9: double free if a nested function has a line break in the
            argument list.
Solution:   Set cmdlinep when freeing the previous line.
Files:      src/userfunc.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.3922/src/userfunc.c      2021-12-27 17:21:38.024449102 +0000
--- src/userfunc.c      2021-12-28 17:18:47.491285907 +0000
***************
*** 219,224 ****
--- 219,226 ----
            if (theline == NULL)
                break;
            vim_free(*line_to_free);
+           if (*eap->cmdlinep == *line_to_free)
+               *eap->cmdlinep = theline;
            *line_to_free = theline;
            whitep = (char_u *)" ";
            p = skipwhite(theline);
*** ../vim-8.2.3922/src/testdir/test_vim9_func.vim      2021-12-26 
14:22:55.665931067 +0000
--- src/testdir/test_vim9_func.vim      2021-12-28 17:17:17.567445742 +0000
***************
*** 1669,1675 ****
    assert_fails('FuncWithForwardCall()', 'E1096:', '', 1, 
'FuncWithForwardCall')
  enddef
  
! def Test_nested_functin_with_nextcmd()
    var lines =<< trim END
        vim9script
        # Define an outer function
--- 1669,1675 ----
    assert_fails('FuncWithForwardCall()', 'E1096:', '', 1, 
'FuncWithForwardCall')
  enddef
  
! def Test_nested_function_with_nextcmd()
    var lines =<< trim END
        vim9script
        # Define an outer function
***************
*** 1689,1694 ****
--- 1689,1712 ----
    CheckScriptFailure(lines, 'E476: Invalid command: AAAAA')
  enddef
  
+ def Test_nested_function_with_args_split()
+   var lines =<< trim END
+       vim9script
+       def FirstFunction()
+         def SecondFunction(
+         )
+         # had a double free if the right parenthesis of the nested function is
+         # on the next line
+          
+         enddef|BBBB
+       enddef
+       # Compile all functions
+       defcompile
+   END
+   # FIXME: this should fail on the BBBB
+   CheckScriptSuccess(lines)
+ enddef
+ 
  def Test_return_type_wrong()
    CheckScriptFailure([
          'def Func(): number',
*** ../vim-8.2.3922/src/version.c       2021-12-28 15:51:40.079738196 +0000
--- src/version.c       2021-12-28 17:15:16.239664174 +0000
***************
*** 751,752 ****
--- 751,754 ----
  {   /* Add new patch number below this line */
+ /**/
+     3923,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
129. You cancel your newspaper subscription.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211228172354.26A181C0641%40moolenaar.net.

Raspunde prin e-mail lui