mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.0419: various memory leaks in Vim9 script code
Problem: Various memory leaks in Vim9 script code. Solution: Fix the leaks. (Ozaki Kiichi, closes #5814)
This commit is contained in:
@@ -283,6 +283,7 @@ call_ufunc(ufunc_T *ufunc, int argcount, ectx_T *ectx, isn_T *iptr)
|
||||
// that was defined later: we can call it directly next time.
|
||||
if (iptr != NULL)
|
||||
{
|
||||
delete_instr(iptr);
|
||||
iptr->isn_type = ISN_DCALL;
|
||||
iptr->isn_arg.dfunc.cdf_idx = ufunc->uf_dfunc_idx;
|
||||
iptr->isn_arg.dfunc.cdf_argcount = argcount;
|
||||
@@ -480,11 +481,21 @@ call_def_function(
|
||||
for (;;)
|
||||
{
|
||||
isn_T *iptr;
|
||||
trycmd_T *trycmd = NULL;
|
||||
|
||||
veryfast_breakcheck();
|
||||
if (got_int)
|
||||
{
|
||||
// Turn CTRL-C into an exception.
|
||||
got_int = FALSE;
|
||||
if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) != FAIL)
|
||||
goto failed;
|
||||
did_throw = TRUE;
|
||||
}
|
||||
|
||||
if (did_throw && !ectx.ec_in_catch)
|
||||
{
|
||||
garray_T *trystack = &ectx.ec_trystack;
|
||||
trycmd_T *trycmd = NULL;
|
||||
|
||||
// An exception jumps to the first catch, finally, or returns from
|
||||
// the current function.
|
||||
@@ -782,8 +793,9 @@ call_def_function(
|
||||
// store $ENV
|
||||
case ISN_STOREENV:
|
||||
--ectx.ec_stack.ga_len;
|
||||
vim_setenv_ext(iptr->isn_arg.string,
|
||||
tv_get_string(STACK_TV_BOT(0)));
|
||||
tv = STACK_TV_BOT(0);
|
||||
vim_setenv_ext(iptr->isn_arg.string, tv_get_string(tv));
|
||||
clear_tv(tv);
|
||||
break;
|
||||
|
||||
// store @r
|
||||
@@ -1038,6 +1050,7 @@ call_def_function(
|
||||
case ISN_RETURN:
|
||||
{
|
||||
garray_T *trystack = &ectx.ec_trystack;
|
||||
trycmd_T *trycmd = NULL;
|
||||
|
||||
if (trystack->ga_len > 0)
|
||||
trycmd = ((trycmd_T *)trystack->ga_data)
|
||||
@@ -1146,6 +1159,8 @@ call_def_function(
|
||||
// start of ":try" block
|
||||
case ISN_TRY:
|
||||
{
|
||||
trycmd_T *trycmd = NULL;
|
||||
|
||||
if (ga_grow(&ectx.ec_trystack, 1) == FAIL)
|
||||
goto failed;
|
||||
trycmd = ((trycmd_T *)ectx.ec_trystack.ga_data)
|
||||
@@ -1180,7 +1195,7 @@ call_def_function(
|
||||
|
||||
if (trystack->ga_len > 0)
|
||||
{
|
||||
trycmd = ((trycmd_T *)trystack->ga_data)
|
||||
trycmd_T *trycmd = ((trycmd_T *)trystack->ga_data)
|
||||
+ trystack->ga_len - 1;
|
||||
trycmd->tcd_caught = TRUE;
|
||||
}
|
||||
@@ -1196,6 +1211,8 @@ call_def_function(
|
||||
|
||||
if (trystack->ga_len > 0)
|
||||
{
|
||||
trycmd_T *trycmd = NULL;
|
||||
|
||||
--trystack->ga_len;
|
||||
--trylevel;
|
||||
trycmd = ((trycmd_T *)trystack->ga_data)
|
||||
@@ -1677,6 +1694,7 @@ failed:
|
||||
for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx)
|
||||
clear_tv(STACK_TV(idx));
|
||||
vim_free(ectx.ec_stack.ga_data);
|
||||
vim_free(ectx.ec_trystack.ga_data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user