mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
vim-patch:8.2.5146: memory leak when substitute expression nests
Problem: Memory leak when substitute expression nests. Solution: Use an array of expression results.44ddf19ec0
Cherry-pick a comment change from patch 8.2.5057. N/A patches for version.c: vim-patch:8.2.5154: still mentioning version8, some cosmetic issues Problem: Still mentioning version8, some cosmetic issues. Solution: Prefer mentioning version9, cosmetic improvements.abd56da30b
This commit is contained in:
@@ -3468,7 +3468,6 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
|
||||
static int pre_hl_id = 0;
|
||||
pos_T old_cursor = curwin->w_cursor;
|
||||
int start_nsubs;
|
||||
int save_ma = 0;
|
||||
|
||||
bool did_save = false;
|
||||
|
||||
@@ -4060,7 +4059,8 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
|
||||
// there is a replace pattern.
|
||||
if (!cmdpreview || has_second_delim) {
|
||||
long lnum_start = lnum; // save the start lnum
|
||||
save_ma = curbuf->b_p_ma;
|
||||
int save_ma = curbuf->b_p_ma;
|
||||
int save_sandbox = sandbox;
|
||||
if (subflags.do_count) {
|
||||
// prevent accidentally changing the buffer by a function
|
||||
curbuf->b_p_ma = false;
|
||||
@@ -4072,7 +4072,8 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
|
||||
|
||||
// Disallow changing text or switching window in an expression.
|
||||
textlock++;
|
||||
// get length of substitution part
|
||||
// Get length of substitution part, including the NUL.
|
||||
// When it fails sublen is zero.
|
||||
sublen = vim_regsub_multi(®match,
|
||||
sub_firstlnum - regmatch.startpos[0].lnum,
|
||||
(char_u *)sub, (char_u *)sub_firstline, 0,
|
||||
@@ -4083,11 +4084,9 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
|
||||
// the replacement.
|
||||
// Don't keep flags set by a recursive call
|
||||
subflags = subflags_save;
|
||||
if (aborting() || subflags.do_count) {
|
||||
if (sublen == 0 || aborting() || subflags.do_count) {
|
||||
curbuf->b_p_ma = save_ma;
|
||||
if (sandbox > 0) {
|
||||
sandbox--;
|
||||
}
|
||||
sandbox = save_sandbox;
|
||||
goto skip;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user