aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2022-02-12 21:20:29 +0000
committerSean Dewar <seandewar@users.noreply.github.com>2022-02-12 21:23:06 +0000
commit700af0ab1d8e85f1f191f4b97f3dda456b5a9551 (patch)
tree2ac3ca952d19e0767c2c69d0e9cdcf6712b88ed2 /src
parent1b0d6bcd53291d9a9d3e1252976bd22564db4fe5 (diff)
downloadrneovim-700af0ab1d8e85f1f191f4b97f3dda456b5a9551.tar.gz
rneovim-700af0ab1d8e85f1f191f4b97f3dda456b5a9551.tar.bz2
rneovim-700af0ab1d8e85f1f191f4b97f3dda456b5a9551.zip
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. https://github.com/vim/vim/commit/33f3c5985491032d5bdfc30e722e85d5a0285e64
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_cmds.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index f6ef259dbd..306da0ec68 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -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) {