summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-01-20 21:59:39 +0100
committerBram Moolenaar <Bram@vim.org>2020-01-20 21:59:39 +0100
commit538feb56e87c647d9b1cc8522f7650d263096f63 (patch)
tree3af7e268ff5f40569b098789eaedfc93a27a854e
parenta44b3eeafa57d4904a3de86b132008b93404f0fd (diff)
downloadvim-git-8.2.0138.tar.gz
patch 8.2.0138: memory leak when starting a job failsv8.2.0138
Problem: Memory leak when starting a job fails. Solution: Free the list of arguments. (Ozaki Kiichi, closes #5510)
-rw-r--r--src/channel.c6
-rw-r--r--src/testdir/test_channel.vim5
-rw-r--r--src/version.c2
3 files changed, 12 insertions, 1 deletions
diff --git a/src/channel.c b/src/channel.c
index fc6a7a37b..cd791b59b 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -5818,9 +5818,9 @@ job_start(
char_u *cmd = NULL;
char **argv = NULL;
int argc = 0;
+ int i;
#if defined(UNIX)
# define USE_ARGV
- int i;
#else
garray_T ga;
#endif
@@ -5994,7 +5994,11 @@ theend:
vim_free(ga.ga_data);
#endif
if (argv != job->jv_argv)
+ {
+ for (i = 0; argv[i] != NULL; i++)
+ vim_free(argv[i]);
vim_free(argv);
+ }
free_job_options(&opt);
return job;
}
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index 4dac7aaef..dace45b64 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -1977,3 +1977,8 @@ func Test_zz_ch_log()
call assert_match("%s%s", text[2])
call delete('Xlog')
endfunc
+
+func Test_job_start_fails()
+ " this was leaking memory
+ call assert_fails("call job_start([''])", "E474:")
+endfunc
diff --git a/src/version.c b/src/version.c
index 6a1702e85..ec77e872e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 138,
+/**/
137,
/**/
136,