Patch 9.0.1225
Problem: Reading past the end of a line when formatting text.
Solution: Check for not going over the end of the line.
Files: src/textformat.c
*** ../vim-9.0.1224/src/textformat.c 2022-10-04 16:23:39.018042176 +0100
--- src/textformat.c 2023-01-21 13:06:36.626667364 +0000
***************
*** 540,545 ****
--- 540,548 ----
if (leader1_len == 0)
return (leader2_len == 0);
+ char_u *lnum_line = NULL;
+ int line_len = 0;
+
// If first leader has 'f' flag, the lines can be joined only if the
// second line does not have a leader.
// If first leader has 'e' flag, the lines can never be joined.
***************
*** 555,561 ****
return FALSE;
if (*p == COM_START)
{
! if (*(ml_get(lnum) + leader1_len) == NUL)
return FALSE;
if (leader2_flags == NULL || leader2_len == 0)
return FALSE;
--- 558,569 ----
return FALSE;
if (*p == COM_START)
{
! if (lnum_line == NULL)
! {
! lnum_line = ml_get(lnum);
! line_len = (int)STRLEN(lnum_line);
! }
! if (line_len <= leader1_len)
return FALSE;
if (leader2_flags == NULL || leader2_len == 0)
return FALSE;
*** ../vim-9.0.1224/src/version.c 2023-01-20 18:49:42.767170965 +0000
--- src/version.c 2023-01-21 13:03:31.246678241 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1225,
/**/
--
Q. What happens to programmers when they die?
A: MS-Windows programmers are reinstalled. C++ programmers become undefined,
anyone who refers to them will die as well. Java programmers reincarnate
after being garbage collected, unless they are in permgen, in which case
they become zombies. Zimbu programmers leave a stack trace that tells us
exactly where they died and how they got there.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20230121130952.D10621C03AF%40moolenaar.net.