diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-09-04 21:20:41 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-09-04 21:20:41 +0200 |
commit | 2ddb89f8a94425cda1e5491efc80c1ccccb6e08e (patch) | |
tree | 8cfdf6756d686a32956f521bd1fcd5018a8fd5ef | |
parent | b7081e135a16091c93f6f5f7525a5c58fb7ca9f9 (diff) | |
download | vim-git-2ddb89f8a94425cda1e5491efc80c1ccccb6e08e.tar.gz |
patch 8.2.3403: memory leak for :retab with invalid argumentv8.2.3403
Problem: Memory leak for :retab with invalid argument.
Solution: Free the memory. Make error messages consistent.
-rw-r--r-- | src/indent.c | 13 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/indent.c b/src/indent.c index cd03f25d2..51af4df06 100644 --- a/src/indent.c +++ b/src/indent.c @@ -70,9 +70,12 @@ tabstop_set(char_u *var, int **array) { int n = atoi((char *)cp); + // Catch negative values, overflow and ridiculous big values. if (n < 0 || n > 9999) { semsg(_(e_invarg2), cp); + vim_free(*array); + *array = NULL; return FAIL; } (*array)[t++] = n; @@ -1615,12 +1618,18 @@ ex_retab(exarg_T *eap) else new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str); #else - new_ts = getdigits(&(eap->arg)); - if (new_ts < 0) + ptr = eap->arg; + new_ts = getdigits(&ptr); + if (new_ts < 0 && *eap->arg == '-') { emsg(_(e_positive)); return; } + if (new_ts < 0 || new_ts > 9999) + { + semsg(_(e_invarg2), eap->arg); + return; + } if (new_ts == 0) new_ts = curbuf->b_p_ts; #endif diff --git a/src/version.c b/src/version.c index a5e931cfa..97467aab9 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3403, +/**/ 3402, /**/ 3401, |