Patch 8.2.3951
Problem:    Vim9: memory leak when text after a nested function.
Solution:   Free the function if text is found after "enddef".
Files:      src/vim9compile.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.3950/src/vim9compile.c   2021-12-28 17:55:22.963786520 +0000
--- src/vim9compile.c   2021-12-30 16:54:37.720422137 +0000
***************
*** 889,894 ****
--- 889,895 ----
        semsg(_(e_text_found_after_str_str),
              eap->cmdidx == CMD_def ? "enddef" : "endfunction", eap->nextcmd);
        r = FAIL;
+       func_ptr_unref(ufunc);
        goto theend;
      }
  
*** ../vim-8.2.3950/src/testdir/test_vim9_func.vim      2021-12-28 
17:55:22.963786520 +0000
--- src/testdir/test_vim9_func.vim      2021-12-30 17:05:18.075367940 +0000
***************
*** 1493,1501 ****
  enddef
  
  def Test_using_var_as_arg()
!   writefile(['def Func(x: number)',  'var x = 234', 'enddef', 'defcompile'], 
'Xdef')
!   assert_fails('so Xdef', 'E1006:', '', 1, 'Func')
!   delete('Xdef')
  enddef
  
  def DictArg(arg: dict<string>)
--- 1493,1512 ----
  enddef
  
  def Test_using_var_as_arg()
!   var lines =<< trim END
!       def Func(x: number)
!         var x = 234
!       enddef
!   END
!   CheckDefFailure(lines, 'E1006:')
! 
!   lines =<< trim END
!       def Func(Ref: number)
!         def Ref()
!         enddef
!       enddef
!   END
!   CheckDefFailure(lines, 'E1073:')
  enddef
  
  def DictArg(arg: dict<string>)
*** ../vim-8.2.3950/src/version.c       2021-12-30 15:29:14.284333311 +0000
--- src/version.c       2021-12-30 16:55:49.612302129 +0000
***************
*** 751,752 ****
--- 751,754 ----
  {   /* Add new patch number below this line */
+ /**/
+     3951,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
158. You get a tuner card so you can watch TV while surfing.

 /// 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/20211230171011.CD7151C0A5B%40moolenaar.net.

Raspunde prin e-mail lui