]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0138: memory leak when starting a job fails v8.2.0138
authorBram Moolenaar <Bram@vim.org>
Mon, 20 Jan 2020 20:59:39 +0000 (21:59 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 20 Jan 2020 20:59:39 +0000 (21:59 +0100)
Problem:    Memory leak when starting a job fails.
Solution:   Free the list of arguments. (Ozaki Kiichi, closes #5510)

src/channel.c
src/testdir/test_channel.vim
src/version.c

index fc6a7a37bb46e6f12b28b74f5f519f1bc2474191..cd791b59b0153ed935b7a4b614df7032d0117340 100644 (file)
@@ -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;
 }
index 4dac7aaef8f3699bd5ba04017edde6df605d2160..dace45b64e361e8a29eaaf66ea8ce491196e5a4d 100644 (file)
@@ -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
index 6a1702e852a9533a64bb286eef24fa6ee1c5307a..ec77e872e61154d1940fa0ccfbd7d7ac8168a89a 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    138,
 /**/
     137,
 /**/