Patch 8.2.2663
Problem: Vim9: leaking memory when inline function has an error.
Solution: Free the partially allocated function.
Files: src/userfunc.c
*** ../vim-8.2.2662/src/userfunc.c 2021-03-22 20:48:57.863992154 +0100
--- src/userfunc.c 2021-03-27 15:29:33.025576116 +0100
***************
*** 35,40 ****
--- 35,42 ----
static char *e_nofunc = N_("E130: Unknown function: %s");
static void funccal_unref(funccall_T *fc, ufunc_T *fp, int force);
+ static void func_clear(ufunc_T *fp, int force);
+ static int func_free(ufunc_T *fp, int force);
void
func_init()
***************
*** 946,952 ****
{
int evaluate = evalarg != NULL
&& (evalarg->eval_flags & EVAL_EVALUATE);
! ufunc_T *ufunc;
exarg_T eap;
garray_T newlines;
char_u *cmdline = NULL;
--- 948,954 ----
{
int evaluate = evalarg != NULL
&& (evalarg->eval_flags & EVAL_EVALUATE);
! ufunc_T *ufunc = NULL;
exarg_T eap;
garray_T newlines;
char_u *cmdline = NULL;
***************
*** 1000,1009 ****
goto erret;
set_ufunc_name(ufunc, name);
if (hash_add(&func_hashtab, UF2HIKEY(ufunc)) == FAIL)
- {
- vim_free(ufunc);
goto erret;
- }
ufunc->uf_refcount = 1;
ufunc->uf_args = *newargs;
newargs->ga_data = NULL;
--- 1002,1008 ----
***************
*** 1045,1050 ****
--- 1044,1050 ----
rettv->vval.v_partial = pt;
rettv->v_type = VAR_PARTIAL;
+ ufunc = NULL;
ret = OK;
erret:
***************
*** 1054,1059 ****
--- 1054,1064 ----
ga_clear_strings(&newlines);
ga_clear_strings(newargs);
ga_clear_strings(default_args);
+ if (ufunc != NULL)
+ {
+ func_clear(ufunc, TRUE);
+ func_free(ufunc, TRUE);
+ }
return ret;
}
*** ../vim-8.2.2662/src/version.c 2021-03-27 12:11:29.914607383 +0100
--- src/version.c 2021-03-27 15:15:46.023563491 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2663,
/**/
--
The History of every major Galactic Civilization tends to pass through
three distinct and recognizable phases, those of Survival, Inquiry and
Sophistication, otherwise known as the How, Why and Where phases.
For instance, the first phase is characterized by the question 'How can
we eat?' the second by the question 'Why do we eat?' and the third by
the question 'Where shall we have lunch?'
-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
/// 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/202103271440.12REedwU608196%40masaka.moolenaar.net.