changeset 19157:f2c8bc90f3c8 v8.2.0138

patch 8.2.0138: memory leak when starting a job fails Commit: https://github.com/vim/vim/commit/538feb56e87c647d9b1cc8522f7650d263096f63 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 20 21:59:39 2020 +0100 patch 8.2.0138: memory leak when starting a job fails Problem: Memory leak when starting a job fails. Solution: Free the list of arguments. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/5510)
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 Jan 2020 22:00:04 +0100
parents 5ad73bc6f845
children c43e9d4d8c93
files src/channel.c src/testdir/test_channel.vim src/version.c
diffstat 3 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }
--- 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
--- 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,