From: Bram Moolenaar Date: Sat, 28 Aug 2021 10:30:12 +0000 (+0200) Subject: patch 8.2.3379: crash when using NULL job X-Git-Tag: v8.2.3379 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=271906bc067a8f25422016665001d2e44cf618e2;p=vim patch 8.2.3379: crash when using NULL job Problem: Crash when using NULL job. Solution: Copy static string into buffer. (issue #8260) --- diff --git a/src/job.c b/src/job.c index 884bf64b8..afa9972a7 100644 --- a/src/job.c +++ b/src/job.c @@ -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"; diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 783a41d2c..fa510c7bb 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -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 = {} diff --git a/src/version.c b/src/version.c index a3f0a8db2..c2e07c668 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 3379, /**/ 3378, /**/