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

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