forked from aniani/vim
patch 9.0.0047: using freed memory with recursive substitute
Problem: Using freed memory with recursive substitute. Solution: Always make a copy for reg_prev_sub.
This commit is contained in:
@@ -1766,11 +1766,11 @@ regtilde(char_u *source, int magic)
|
||||
}
|
||||
}
|
||||
|
||||
// Store a copy of newsub in reg_prev_sub. It is always allocated,
|
||||
// because recursive calls may make the returned string invalid.
|
||||
vim_free(reg_prev_sub);
|
||||
if (newsub != source) // newsub was allocated, just keep it
|
||||
reg_prev_sub = newsub;
|
||||
else // no ~ found, need to save newsub
|
||||
reg_prev_sub = vim_strsave(newsub);
|
||||
reg_prev_sub = vim_strsave(newsub);
|
||||
|
||||
return newsub;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user