]> granicus.if.org Git - vim/commitdiff
patch 8.2.4219: reading before the start of the line v8.2.4219
authorBram Moolenaar <Bram@vim.org>
Tue, 25 Jan 2022 21:26:17 +0000 (21:26 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 25 Jan 2022 21:26:17 +0000 (21:26 +0000)
Problem:    Reading before the start of the line.
Solution:   Check boundary before trying to read the character.

src/register.c
src/testdir/test_visual.vim
src/version.c

index d604bae6b0debf1729c625e4ddc2412429f0bb02..03f7f4ec9604ce569913646d19c687ac91828926 100644 (file)
@@ -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--;
index b2beda08d0aa84337c0f40c3e593d9900b924910..af54615c48a104985b203d4ae27e899a78a048f1 100644 (file)
@@ -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
 
index 9dcf34928f8def6287afaf0346fa4b66d497c97d..a3efb046bdf5833491d97ca81729091531a87783 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4219,
 /**/
     4218,
 /**/