To: vim_dev@googlegroups.com Subject: Patch 8.2.4362 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///