Patch 8.2.3951

8 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 30, 2021, 12:10:16 PM12/30/21
to vim...@googlegroups.com

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 -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages