diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-03-05 08:08:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-05 08:08:04 +0800 |
commit | 089f962d6a18bd91d89998e16834b822ab2adf9f (patch) | |
tree | 73dcbb373962584e4b74f89f51cf7c3d17df0a7c | |
parent | 39842be8cd8808c7da2638a6cc84d7c3fe40b996 (diff) | |
download | rneovim-089f962d6a18bd91d89998e16834b822ab2adf9f.tar.gz rneovim-089f962d6a18bd91d89998e16834b822ab2adf9f.tar.bz2 rneovim-089f962d6a18bd91d89998e16834b822ab2adf9f.zip |
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.
https://github.com/vim/vim/commit/c99cbf8f289bdda5d4a77d7ec415850a520330ba
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | src/nvim/ops.c | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test_virtualedit.vim | 10 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 884eeef433..6929189750 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -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); if (ce != cs && oap->start.coladd > 0) { // Part of a tab selected -- but don't double-count it. - bd.startspaces = (ce - cs + 1) - - oap->start.coladd; + bd.startspaces = (ce - cs + 1) - oap->start.coladd; + if (bd.startspaces < 0) { + bd.startspaces = 0; + } startcol++; } } diff --git a/src/nvim/testdir/test_virtualedit.vim b/src/nvim/testdir/test_virtualedit.vim index 20a5f87517..a2baf276ac 100644 --- a/src/nvim/testdir/test_virtualedit.vim +++ b/src/nvim/testdir/test_virtualedit.vim @@ -88,6 +88,16 @@ func Test_edit_change() set virtualedit= 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 " in virtual edit mode. func Test_paste_in_tab() |