]> granicus.if.org Git - vim/commitdiff
patch 8.2.3678: illegal memory access v8.2.3678
authorBram Moolenaar <Bram@vim.org>
Thu, 25 Nov 2021 20:40:11 +0000 (20:40 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 25 Nov 2021 20:40:11 +0000 (20:40 +0000)
Problem:    Illegal memory access.
Solution:   Ignore changed indent when computing byte offset.

src/register.c
src/version.c

index 00b8b4bb34b250757a775a906cb7b5839f6b9d0c..3fc8b6340c2730a76db85ff26b963a7eb2ab6030 100644 (file)
@@ -2099,6 +2099,7 @@ do_put(
        else
        {
            linenr_T    new_lnum = new_cursor.lnum;
+           size_t      len;
 
            // Insert at least one line.  When y_type is MCHAR, break the first
            // line in two.
@@ -2211,11 +2212,12 @@ error:
            // Put the '] mark on the first byte of the last inserted character.
            // Correct the length for change in indent.
            curbuf->b_op_end.lnum = new_lnum;
-           col = (colnr_T)STRLEN(y_array[y_size - 1]) - lendiff;
+           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],
-                                               y_array[y_size - 1] + col - 1);
+                                               y_array[y_size - 1] + len - 1);
            else
                curbuf->b_op_end.col = 0;
 
index 0adbdb797c7a2d4fe1b29b7fe46d459bd9b31097..b7a93edbb2b388e2236dc9e2eee1986116bbbb5c 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3678,
 /**/
     3677,
 /**/