diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-25 21:26:17 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-25 21:26:17 +0000 |
commit | 44db8213d38c39877d2148eff6a72f4beccfb94e (patch) | |
tree | eb335ea046fce7c378c65893ddb4ea2c1e27458b | |
parent | 806d037671e133bd28a7864248763f643967973a (diff) | |
download | vim-git-44db8213d38c39877d2148eff6a72f4beccfb94e.tar.gz |
patch 8.2.4219: reading before the start of the linev8.2.4219
Problem: Reading before the start of the line.
Solution: Check boundary before trying to read the character.
-rw-r--r-- | src/register.c | 2 | ||||
-rw-r--r-- | src/testdir/test_visual.vim | 7 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/src/register.c b/src/register.c index d604bae6b..03f7f4ec9 100644 --- a/src/register.c +++ b/src/register.c @@ -1474,7 +1474,7 @@ yank_copy_line(struct block_def *bd, long y_idx, int exclude_trailing_space) { int s = bd->textlen + bd->endspaces; - while (VIM_ISWHITE(*(bd->textstart + s - 1)) && s > 0) + while (s > 0 && VIM_ISWHITE(*(bd->textstart + s - 1))) { s = s - (*mb_head_off)(bd->textstart, bd->textstart + s - 1) - 1; pnew--; diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim index b2beda08d..af54615c4 100644 --- a/src/testdir/test_visual.vim +++ b/src/testdir/test_visual.vim @@ -1247,6 +1247,13 @@ func Test_visual_put_blockedit_zy_and_zp() bw! endfunc +func Test_visual_block_yank_zy() + new + " this was reading before the start of the line + exe "norm o\<C-T>\<Esc>\<C-V>zy" + bwipe! +endfunc + func Test_visual_block_with_virtualedit() CheckScreendump diff --git a/src/version.c b/src/version.c index 9dcf34928..a3efb046b 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4219, +/**/ 4218, /**/ 4217, |