summaryrefslogtreecommitdiffstats
path: root/debian/patches/upstream/patch-8.2.3403-memory-leak-for-retab-with-invalid-argumen.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/upstream/patch-8.2.3403-memory-leak-for-retab-with-invalid-argumen.patch')
-rw-r--r--debian/patches/upstream/patch-8.2.3403-memory-leak-for-retab-with-invalid-argumen.patch61
1 files changed, 61 insertions, 0 deletions
diff --git a/debian/patches/upstream/patch-8.2.3403-memory-leak-for-retab-with-invalid-argumen.patch b/debian/patches/upstream/patch-8.2.3403-memory-leak-for-retab-with-invalid-argumen.patch
new file mode 100644
index 0000000..a02728b
--- /dev/null
+++ b/debian/patches/upstream/patch-8.2.3403-memory-leak-for-retab-with-invalid-argumen.patch
@@ -0,0 +1,61 @@
+From: Bram Moolenaar <Bram@vim.org>
+Date: Sat, 4 Sep 2021 21:20:41 +0200
+Subject: patch 8.2.3403: memory leak for :retab with invalid argument
+
+Problem: Memory leak for :retab with invalid argument.
+Solution: Free the memory. Make error messages consistent.
+---
+ src/indent.c | 13 +++++++++++--
+ src/version.c | 1 +
+ 2 files changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/src/indent.c b/src/indent.c
+index 9209a39..a43413c 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;
+@@ -1584,12 +1587,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 c5617f6..c3c64d5 100644
+--- a/src/version.c
++++ b/src/version.c
+@@ -5632,6 +5632,7 @@ static int included_patches[] =
+ static char *(extra_patches[]) =
+ { /* Add your patch description below this line */
+ "8.2.3402",
++ "8.2.3403",
+ /**/
+ NULL
+ };