Skip to content

Commit

Permalink
patch 8.2.0138: memory leak when starting a job fails
Browse files Browse the repository at this point in the history
Problem:    Memory leak when starting a job fails.
Solution:   Free the list of arguments. (Ozaki Kiichi, closes #5510)
  • Loading branch information
brammool committed Jan 20, 2020
1 parent a44b3ee commit 538feb5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/channel.c
Expand Up @@ -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
Expand Down Expand Up @@ -5994,7 +5994,11 @@ job_start(
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;
}
Expand Down
5 changes: 5 additions & 0 deletions src/testdir/test_channel.vim
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -742,6 +742,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
138,
/**/
137,
/**/
Expand Down

0 comments on commit 538feb5

Please sign in to comment.