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

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