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

423208
diff -up vim82/src/charset.c.cve4193 vim82/src/charset.c
423208
--- vim82/src/charset.c.cve4193	2021-03-22 10:02:42.000000000 +0100
423208
+++ vim82/src/charset.c	2022-01-13 10:14:55.634913386 +0100
423208
@@ -1232,10 +1232,15 @@ getvcol(
423208
 	posptr = NULL;  // continue until the NUL
423208
     else
423208
     {
423208
-	// Special check for an empty line, which can happen on exit, when
423208
-	// ml_get_buf() always returns an empty string.
423208
-	if (*ptr == NUL)
423208
-	    pos->col = 0;
423208
+	colnr_T i;
423208
+
423208
+	// In a few cases the position can be beyond the end of the line.
423208
+	for (i = 0; i < pos->col; ++i)
423208
+	    if (ptr[i] == NUL)
423208
+	    {
423208
+		pos->col = i;
423208
+		break;
423208
+	    }
423208
 	posptr = ptr + pos->col;
423208
 	if (has_mbyte)
423208
 	    // always start on the first byte
423208
diff -up vim82/src/testdir/test_regexp_latin.vim.cve4193 vim82/src/testdir/test_regexp_latin.vim
423208
--- vim82/src/testdir/test_regexp_latin.vim.cve4193	2022-01-13 10:14:55.634913386 +0100
423208
+++ vim82/src/testdir/test_regexp_latin.vim	2022-01-13 10:17:01.905292715 +0100
423208
@@ -938,4 +938,12 @@ func Test_regexp_last_subst_string()
423208
   close!
423208
 endfunc
423208
 
423208
+func Test_using_invalid_visual_position()
423208
+  " this was going beyond the end of the line
423208
+  new
423208
+  exe "norm 0o000\<Esc>0\<C-V>$s0"
423208
+  /\%V
423208
+  bwipe!
423208
+endfunc
423208
+
423208
 " vim: shiftwidth=2 sts=2 expandtab