Blame SOURCES/0001-patch-8.2.4151-reading-beyond-the-end-of-a-line.patch

b6500d
diff --git a/src/ops.c b/src/ops.c
b6500d
index e9cfb1d..e35b033 100644
b6500d
--- a/src/ops.c
b6500d
+++ b/src/ops.c
b6500d
@@ -629,26 +629,9 @@ block_insert(
b6500d
 
b6500d
 #ifdef FEAT_MBYTE
b6500d
 	if (has_mbyte && spaces > 0)
b6500d
-	{
b6500d
-	    int off;
b6500d
+	    // avoid copying part of a multi-byte character
b6500d
+	    offset -= (*mb_head_off)(oldp, oldp + offset);
b6500d
 
b6500d
-	    /* Avoid starting halfway a multi-byte character. */
b6500d
-	    if (b_insert)
b6500d
-	    {
b6500d
-		off = (*mb_head_off)(oldp, oldp + offset + spaces);
b6500d
-		spaces -= off;
b6500d
-		count -= off;
b6500d
-	    }
b6500d
-	    else
b6500d
-	    {
b6500d
-		// spaces fill the gap, the character that's at the edge moves
b6500d
-		// right
b6500d
-		off = (*mb_head_off)(oldp, oldp + offset);
b6500d
-		offset -= off;
b6500d
-	    }
b6500d
-	    spaces -= off;
b6500d
-	    count -= off;
b6500d
-	}
b6500d
 #endif
b6500d
 
b6500d
 	// Make sure the allocated size matches what is actually copied below.
b6500d
diff --git a/src/testdir/test_utf8.vim b/src/testdir/test_utf8.vim
b6500d
index 24e3db8..1042720 100644
b6500d
--- a/src/testdir/test_utf8.vim
b6500d
+++ b/src/testdir/test_utf8.vim
b6500d
@@ -9,7 +9,7 @@ func Test_visual_block_insert()
b6500d
   new
b6500d
   call setline(1, ["aaa", "あああ", "bbb"])
b6500d
   exe ":norm! gg0l\<C-V>jjIx\<Esc>"
b6500d
-  call assert_equal(['axaa', 'xあああ', 'bxbb'], getline(1, '$'))
b6500d
+  call assert_equal(['axaa', ' xあああ', 'bxbb'], getline(1, '$'))
b6500d
   bwipeout!
b6500d
 endfunc
b6500d