Patch 8.2.2791
Problem: Vim9: memory leak when using \=expr in :substitute.
Solution: Do not allocate a new instruction list.
Files: src/vim9compile.c
*** ../vim-8.2.2790/src/vim9compile.c 2021-04-20 21:10:44.818613886 +0200
--- src/vim9compile.c 2021-04-20 21:47:54.923908630 +0200
***************
*** 8544,8552 ****
cmd = skipwhite(cmd);
trailing_error = *cmd != delimiter && *cmd != NUL;
! instr_count = cctx->ctx_instr.ga_len;
! instr = ALLOC_MULT(isn_T, instr_count + 1);
! if (trailing_error || instr == NULL)
{
if (trailing_error)
semsg(_(e_trailing_arg), cmd);
--- 8544,8550 ----
cmd = skipwhite(cmd);
trailing_error = *cmd != delimiter && *cmd != NUL;
! if (trailing_error || ga_grow(&cctx->ctx_instr, 1) == FAIL)
{
if (trailing_error)
semsg(_(e_trailing_arg), cmd);
***************
*** 8559,8566 ****
// Move the generated instructions into the ISN_SUBSTITUTE
// instructions, then restore the list of instructions before
// adding the ISN_SUBSTITUTE instruction.
! mch_memmove(instr, cctx->ctx_instr.ga_data,
! instr_count * sizeof(isn_T));
instr[instr_count].isn_type = ISN_FINISH;
cctx->ctx_instr = save_ga;
--- 8557,8564 ----
// Move the generated instructions into the ISN_SUBSTITUTE
// instructions, then restore the list of instructions before
// adding the ISN_SUBSTITUTE instruction.
! instr_count = cctx->ctx_instr.ga_len;
! instr = cctx->ctx_instr.ga_data;
instr[instr_count].isn_type = ISN_FINISH;
cctx->ctx_instr = save_ga;
*** ../vim-8.2.2790/src/version.c 2021-04-20 21:14:06.389974460 +0200
--- src/version.c 2021-04-20 21:49:06.431733208 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2791,
/**/
--
Why is it called "Windows"? "Gates" would be more appropriate...
/// 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 ///