1
0
forked from aniani/vim

patch 8.2.3379: crash when using NULL job

Problem:    Crash when using NULL job.
Solution:   Copy static string into buffer. (issue #8260)
This commit is contained in:
Bram Moolenaar
2021-08-28 12:30:12 +02:00
parent 6024c0427c
commit 271906bc06
3 changed files with 10 additions and 1 deletions

View File

@@ -1983,7 +1983,10 @@ job_to_string_buf(typval_T *varp, char_u *buf)
char *status;
if (job == NULL)
return (char_u *)"no process";
{
vim_snprintf((char *)buf, NUMBUFLEN, "no process");
return buf;
}
status = job->jv_status == JOB_FAILED ? "fail"
: job->jv_status >= JOB_ENDED ? "dead"
: "run";

View File

@@ -1718,6 +1718,10 @@ func Test_job_stop_immediately()
endtry
endfunc
func Test_null_job_eval()
call assert_fails('eval test_null_job()->eval()', 'E121:')
endfunc
" This was leaking memory.
func Test_partial_in_channel_cycle()
let d = {}

View File

@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3379,
/**/
3378,
/**/