]> granicus.if.org Git - vim/commitdiff
patch 8.2.5016: access before start of text with a put command v8.2.5016
authorBram Moolenaar <Bram@vim.org>
Wed, 25 May 2022 14:15:38 +0000 (15:15 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 25 May 2022 14:15:38 +0000 (15:15 +0100)
Problem:    Access before start of text with a put command.
Solution:   Check the length is more than zero.

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

index 5ebaa05dbf091fd7ab26ea678225cd20c2eb314a..d5a56ae0c604de8007d7a1c0427f43c600093e93 100644 (file)
@@ -2219,9 +2219,12 @@ error:
            len = STRLEN(y_array[y_size - 1]);
            col = (colnr_T)len - lendiff;
            if (col > 1)
-               curbuf->b_op_end.col = col - 1
-                               - mb_head_off(y_array[y_size - 1],
+           {
+               curbuf->b_op_end.col = col - 1;
+               if (len > 0)
+                   curbuf->b_op_end.col -= mb_head_off(y_array[y_size - 1],
                                                y_array[y_size - 1] + len - 1);
+           }
            else
                curbuf->b_op_end.col = 0;
 
index 0fde026401a9b54dbd55324192bd674b0e1d5152..aa5aa2b9906167ac570ce9b7e36fe932f62a44e3 100644 (file)
@@ -210,5 +210,14 @@ func Test_multibyte_op_end_mark()
   bwipe!
 endfunc
 
+" this was putting a mark before the start of a line
+func Test_put_empty_register()
+  new
+  norm yy
+  norm [Pi00\14\14\ 3ggv)s0
+  sil! norm [P
+  bwipe!
+endfunc
+
 
 " vim: shiftwidth=2 sts=2 expandtab
index 4682108ff8e62f9738999a6dfc461da16bfe8271..250b73e7afff9f5cbccb7a59e1c89157df794efb 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5016,
 /**/
     5015,
 /**/