aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds.c
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2022-02-12 22:51:13 +0000
committerGitHub <noreply@github.com>2022-02-12 22:51:13 +0000
commit7a7ac004f0288d693443804b8bed9bc233926dad (patch)
tree36e627ff60b74516f88fd5ff613453573f8564f5 /src/nvim/ex_cmds.c
parent05f744cfc7411cd22320116f20ebcc1d06443fea (diff)
parent5c62bce7c12638c217f8297212698ed10bb5543b (diff)
downloadrneovim-7a7ac004f0288d693443804b8bed9bc233926dad.tar.gz
rneovim-7a7ac004f0288d693443804b8bed9bc233926dad.tar.bz2
rneovim-7a7ac004f0288d693443804b8bed9bc233926dad.zip
Merge pull request #17385 from seandewar/vim-8.2.4359
vim-patch:8.2.{4359,4362,4363,4364}: crash when repeatedly using :retab
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r--src/nvim/ex_cmds.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index fd1e34803f..49bf9972b1 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 <= 0 || new_len >= MAXCOL) {
+ emsg(_(e_resulting_text_too_long));
+ break;
+ }
new_line = xmalloc(new_len);
if (start_col > 0) {
@@ -847,6 +851,10 @@ void ex_retab(exarg_T *eap)
break;
}
vcol += win_chartabsize(curwin, ptr + col, (colnr_T)vcol);
+ if (vcol >= MAXCOL) {
+ emsg(_(e_resulting_text_too_long));
+ break;
+ }
col += utfc_ptr2len(ptr + col);
}
if (new_line == NULL) { // out of memory