Blame SOURCES/0001-patch-8.2.4563-z-in-Visual-mode-may-go-beyond-the-en.patch

83f671
diff -up vim82/src/spellsuggest.c.cve0943 vim82/src/spellsuggest.c
83f671
--- vim82/src/spellsuggest.c.cve0943	2022-03-28 20:48:07.079197805 +0200
83f671
+++ vim82/src/spellsuggest.c	2022-03-28 20:48:07.101197522 +0200
83f671
@@ -501,6 +501,10 @@ spell_suggest(int count)
83f671
 	    curwin->w_cursor.col = VIsual.col;
83f671
 	++badlen;
83f671
 	end_visual_mode();
83f671
+	// make sure we don't include the NUL at the end of the line
83f671
+	line = ml_get_curline();
83f671
+	if (badlen > STRLEN(line) - curwin->w_cursor.col)
83f671
+	    badlen = STRLEN(line) - curwin->w_cursor.col;
83f671
     }
83f671
     // Find the start of the badly spelled word.
83f671
     else if (spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL) == 0
83f671
diff -up vim82/src/testdir/test_spell.vim.cve0943 vim82/src/testdir/test_spell.vim
83f671
--- vim82/src/testdir/test_spell.vim.cve0943	2022-03-28 20:48:07.102197509 +0200
83f671
+++ vim82/src/testdir/test_spell.vim	2022-03-28 20:49:05.038452974 +0200
83f671
@@ -441,6 +441,21 @@ func Test_spellsuggest_expr_errors()
83f671
   delfunc MySuggest3
83f671
 endfunc
83f671
 
83f671
+func Test_spellsuggest_visual_end_of_line()
83f671
+  let enc_save = &encoding
83f671
+  set encoding=iso8859
83f671
+
83f671
+  " This was reading beyond the end of the line.
83f671
+  norm R00000000000
83f671
+  sil norm ?0
83f671
+  sil! norm ?i00000)
83f671
+  sil! norm ?i00000)
83f671
+  call feedkeys("\<CR>")
83f671
+  norm z=
83f671
+
83f671
+  let &encoding = enc_save
83f671
+endfunc
83f671
+
83f671
 func Test_spellinfo()
83f671
   new
83f671
   let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')