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

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