File vim-8.0.1568-CVE-2021-4193.patch of Package vim.23083

--- vim-8.0.1568.orig/src/charset.c	2022-02-03 20:50:13.621648993 +0200
+++ vim-8.0.1568/src/charset.c	2022-02-16 16:30:19.375801644 +0200
@@ -1291,10 +1291,15 @@
 	posptr = NULL;  /* continue until the NUL */
     else
     {
-	/* Special check for an empty line, which can happen on exit, when
-	 * ml_get_buf() always returns an empty string. */
-	if (*ptr == NUL)
-	    pos->col = 0;
+	colnr_T i;
+
+	// In a few cases the position can be beyond the end of the line.
+	for (i = 0; i < pos->col; ++i)
+	    if (ptr[i] == NUL)
+	    {
+		pos->col = i;
+		break;
+	    }
 	posptr = ptr + pos->col;
 #ifdef FEAT_MBYTE
 	if (has_mbyte)
openSUSE Build Service is sponsored by