Patch 8.2.2505

5 views
Skip to first unread message

Bram Moolenaar

unread,
Feb 12, 2021, 4:11:57 PM2/12/21
to vim...@googlegroups.com

Patch 8.2.2505
Problem: Vim9: crash after defining function with invalid return type.
Solution: Clear function growarrays. Fix memory leak.
Files: src/userfunc.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.2504/src/userfunc.c 2021-02-07 18:06:25.266692335 +0100
--- src/userfunc.c 2021-02-12 22:06:31.955386993 +0100
***************
*** 3955,3962 ****
--- 3955,3969 ----
erret:
ga_clear_strings(&newargs);
ga_clear_strings(&default_args);
+ if (fp != NULL)
+ {
+ ga_init(&fp->uf_args);
+ ga_init(&fp->uf_def_args);
+ }
errret_2:
ga_clear_strings(&newlines);
+ if (fp != NULL)
+ VIM_CLEAR(fp->uf_arg_types);
ret_free:
ga_clear_strings(&argtypes);
vim_free(skip_until);
*** ../vim-8.2.2504/src/testdir/test_vim9_func.vim 2021-02-12 21:50:53.509801284 +0100
--- src/testdir/test_vim9_func.vim 2021-02-12 22:09:19.347353170 +0100
***************
*** 254,259 ****
--- 254,274 ----
defcompile
END
CheckScriptFailure(lines, 'E1010:', 2)
+
+ lines =<< trim END
+ vim9script
+ def Test(Fun: func(number): number): list<number>
+ return map([1, 2, 3], (_, i) => Fun(i))
+ enddef
+ defcompile
+ def Inc(nr: number): nr
+ return nr + 2
+ enddef
+ echo Test(Inc)
+ END
+ # doing this twice was leaking memory
+ CheckScriptFailure(lines, 'E1010:')
+ CheckScriptFailure(lines, 'E1010:')
enddef

func Increment()
*** ../vim-8.2.2504/src/version.c 2021-02-12 21:50:53.509801284 +0100
--- src/version.c 2021-02-12 22:09:48.363334268 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2505,
/**/

--
Windows
M!uqoms

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages