Patch 8.2.4362
Problem: :retab may allocate too much memory.
Solution: Bail out when allocating more than MAXCOL bytes.
Files: src/indent.c
*** ../vim-8.2.4361/src/indent.c 2022-02-12 15:42:14.957142547 +0000
--- src/indent.c 2022-02-12 20:42:09.912213848 +0000
***************
*** 1607,1612 ****
--- 1607,1613 ----
long start_col = 0; // For start of white-space string
long start_vcol = 0; // For start of white-space string
long old_len;
+ long new_len;
char_u *ptr;
char_u *new_line = (char_u *)1; // init to non-NULL
int did_undo; // called u_save for current
line
***************
*** 1724,1730 ****
// len is actual number of white characters used
len = num_spaces + num_tabs;
old_len = (long)STRLEN(ptr);
! new_line = alloc(old_len - col + start_col + len + 1);
if (new_line == NULL)
break;
if (start_col > 0)
--- 1725,1737 ----
// len is actual number of white characters used
len = num_spaces + num_tabs;
old_len = (long)STRLEN(ptr);
! new_len = old_len - col + start_col + len + 1;
! if (new_len >= MAXCOL)
! {
! emsg(_(e_resulting_text_too_long));
! break;
! }
! new_line = alloc(new_len);
if (new_line == NULL)
break;
if (start_col > 0)
*** ../vim-8.2.4361/src/version.c 2022-02-12 20:34:47.088825181 +0000
--- src/version.c 2022-02-12 20:42:58.948147492 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4362,
/**/
--
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/20220212204650.94AD41C0DFF%40moolenaar.net.