vim-patch:8.2.4362: :retab may allocate too much memory

Problem:    :retab may allocate too much memory.
Solution:   Bail out when allocating more than MAXCOL bytes.
33f3c59854
This commit is contained in:
Sean Dewar 2022-02-12 21:20:29 +00:00
parent 1b0d6bcd53
commit 700af0ab1d
No known key found for this signature in database
GPG Key ID: 08CC2C83AD41B581

View File

@ -814,7 +814,11 @@ void ex_retab(exarg_T *eap)
// len is actual number of white characters used
len = num_spaces + num_tabs;
old_len = (long)STRLEN(ptr);
long new_len = old_len - col + start_col + len + 1;
const long new_len = old_len - col + start_col + len + 1;
if (new_len >= MAXCOL) {
emsg(_(e_resulting_text_too_long));
break;
}
new_line = xmalloc(new_len);
if (start_col > 0) {