changeset 26294:ba835881a79e v8.2.3678

patch 8.2.3678: illegal memory access Commit: https://github.com/vim/vim/commit/85be8563fe5aff686e9e30d6afff401ccd976f2a Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 25 20:40:11 2021 +0000 patch 8.2.3678: illegal memory access Problem: Illegal memory access. Solution: Ignore changed indent when computing byte offset.
author Bram Moolenaar <Bram@vim.org>
date Thu, 25 Nov 2021 21:45:03 +0100
parents 0324433f1750
children 84d52b86a6b3
files src/register.c src/version.c
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/register.c
+++ b/src/register.c
@@ -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;
 
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3678,
+/**/
     3677,
 /**/
     3676,