Blame SOURCES/0001-patch-8.2.3950-going-beyond-the-end-of-the-line-with.patch

f27350
diff -up vim80/src/charset.c.cve4193 vim80/src/charset.c
f27350
--- vim80/src/charset.c.cve4193	2022-01-12 14:49:08.710592947 +0100
f27350
+++ vim80/src/charset.c	2022-01-12 14:49:47.594705863 +0100
f27350
@@ -1291,10 +1291,15 @@ getvcol(
f27350
 	posptr = NULL;  /* continue until the NUL */
f27350
     else
f27350
     {
f27350
-	/* Special check for an empty line, which can happen on exit, when
f27350
-	 * ml_get_buf() always returns an empty string. */
f27350
-	if (*ptr == NUL)
f27350
-	    pos->col = 0;
f27350
+	colnr_T i;
f27350
+
f27350
+	// In a few cases the position can be beyond the end of the line.
f27350
+	for (i = 0; i < pos->col; ++i)
f27350
+	    if (ptr[i] == NUL)
f27350
+	    {
f27350
+		pos->col = i;
f27350
+		break;
f27350
+	    }
f27350
 	posptr = ptr + pos->col;
f27350
 #ifdef FEAT_MBYTE
f27350
 	if (has_mbyte)
f27350
diff -up vim80/src/testdir/test_regexp_latin.vim.cve4193 vim80/src/testdir/test_regexp_latin.vim
f27350
--- vim80/src/testdir/test_regexp_latin.vim.cve4193	2022-01-12 14:49:08.710592947 +0100
f27350
+++ vim80/src/testdir/test_regexp_latin.vim	2022-01-12 14:50:45.186873107 +0100
f27350
@@ -72,3 +72,11 @@ func Test_backref()
f27350
   call assert_fails('call search("\\%#=2\\(e\\1\\)")', 'E65:')
f27350
   bwipe!
f27350
 endfunc
f27350
+
f27350
+func Test_using_invalid_visual_position()
f27350
+  " this was going beyond the end of the line
f27350
+  new
f27350
+  exe "norm 0o000\<Esc>0\<C-V>$s0"
f27350
+  /\%V
f27350
+  bwipe!
f27350
+endfunc