aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-03-10 16:40:45 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-03-10 16:43:27 +0800
commitd2d3be0a4a65f623e95b2eac1abf215233ba9f00 (patch)
tree9abcdc7c9a4c1ba205b2a662188b928c735e0c04 /src/nvim/regexp.c
parent9e9322b222566c0f92bb6df034d9b316317c81d5 (diff)
downloadrneovim-d2d3be0a4a65f623e95b2eac1abf215233ba9f00.tar.gz
rneovim-d2d3be0a4a65f623e95b2eac1abf215233ba9f00.tar.bz2
rneovim-d2d3be0a4a65f623e95b2eac1abf215233ba9f00.zip
vim-patch:8.2.3949: using freed memory with /\%V
Problem: Using freed memory with /\%V. Solution: Get the line again after getvvcol(). https://github.com/vim/vim/commit/4c13e5e6763c6eb36a343a2b8235ea227202e952
Diffstat (limited to 'src/nvim/regexp.c')
-rw-r--r--src/nvim/regexp.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 412cdac21b..009a26d4e0 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -1136,8 +1136,8 @@ static bool reg_match_visual(void)
return false;
}
+ col = (colnr_T)(rex.input - rex.line);
if (mode == 'v') {
- col = (colnr_T)(rex.input - rex.line);
if ((lnum == top.lnum && col < top.col)
|| (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e'))) {
return false;
@@ -1152,8 +1152,12 @@ static bool reg_match_visual(void)
if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL) {
end = MAXCOL;
}
- unsigned int cols_u = win_linetabsize(wp, rex.line,
- (colnr_T)(rex.input - rex.line));
+
+ // getvvcol() flushes rex.line, need to get it again
+ rex.line = reg_getline(rex.lnum);
+ rex.input = rex.line + col;
+
+ unsigned int cols_u = win_linetabsize(wp, rex.line, col);
assert(cols_u <= MAXCOL);
colnr_T cols = (colnr_T)cols_u;
if (cols < start || cols > end - (*p_sel == 'e')) {