mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.1378: illegal memory access when using virtual editing (#22527)
Problem: Illegal memory access when using virtual editing.
Solution: Make sure "startspaces" is not negative.
c99cbf8f28
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
39842be8cd
commit
089f962d6a
@ -2684,8 +2684,10 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
|
|||||||
getvcol(curwin, &oap->start, &cs, NULL, &ce);
|
getvcol(curwin, &oap->start, &cs, NULL, &ce);
|
||||||
if (ce != cs && oap->start.coladd > 0) {
|
if (ce != cs && oap->start.coladd > 0) {
|
||||||
// Part of a tab selected -- but don't double-count it.
|
// Part of a tab selected -- but don't double-count it.
|
||||||
bd.startspaces = (ce - cs + 1)
|
bd.startspaces = (ce - cs + 1) - oap->start.coladd;
|
||||||
- oap->start.coladd;
|
if (bd.startspaces < 0) {
|
||||||
|
bd.startspaces = 0;
|
||||||
|
}
|
||||||
startcol++;
|
startcol++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,16 @@ func Test_edit_change()
|
|||||||
set virtualedit=
|
set virtualedit=
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_edit_special_char()
|
||||||
|
new
|
||||||
|
se ve=all
|
||||||
|
norm a0
|
||||||
|
sil! exe "norm o00000\<Nul>k<a0s"
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
set virtualedit=
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Tests for pasting at the beginning, end and middle of a tab character
|
" Tests for pasting at the beginning, end and middle of a tab character
|
||||||
" in virtual edit mode.
|
" in virtual edit mode.
|
||||||
func Test_paste_in_tab()
|
func Test_paste_in_tab()
|
||||||
|
Loading…
Reference in New Issue
Block a user