mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 18:06:30 +00:00
vim-patch:8.2.3949: using freed memory with /\%V
Problem: Using freed memory with /\%V.
Solution: Get the line again after getvvcol().
4c13e5e676
This commit is contained in:
@@ -1136,8 +1136,8 @@ static bool reg_match_visual(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == 'v') {
|
|
||||||
col = (colnr_T)(rex.input - rex.line);
|
col = (colnr_T)(rex.input - rex.line);
|
||||||
|
if (mode == 'v') {
|
||||||
if ((lnum == top.lnum && col < top.col)
|
if ((lnum == top.lnum && col < top.col)
|
||||||
|| (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e'))) {
|
|| (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e'))) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1152,8 +1152,12 @@ static bool reg_match_visual(void)
|
|||||||
if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL) {
|
if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL) {
|
||||||
end = 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);
|
assert(cols_u <= MAXCOL);
|
||||||
colnr_T cols = (colnr_T)cols_u;
|
colnr_T cols = (colnr_T)cols_u;
|
||||||
if (cols < start || cols > end - (*p_sel == 'e')) {
|
if (cols < start || cols > end - (*p_sel == 'e')) {
|
||||||
|
@@ -795,4 +795,12 @@ func Test_using_mark_position()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_using_visual_position()
|
||||||
|
" this was using freed memory
|
||||||
|
new
|
||||||
|
exe "norm 0o\<Esc>\<C-V>k\<C-X>o0"
|
||||||
|
/\%V
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user