Mercurial > vim
diff src/vim9execute.c @ 19726:ad37a198a708 v8.2.0419
patch 8.2.0419: various memory leaks in Vim9 script code
Commit: https://github.com/vim/vim/commit/20431c9dbb592ebe0666bf042af7d2b373107372
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 20 18:39:46 2020 +0100
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 https://github.com/vim/vim/issues/5814)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 20 Mar 2020 18:45:04 +0100 |
parents | d202122a4963 |
children | 4174c4da6ff7 |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -283,6 +283,7 @@ call_ufunc(ufunc_T *ufunc, int argcount, // 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; }