# HG changeset patch # User Bram Moolenaar # Date 1630147506 -7200 # Node ID 838a0108a92d602dda0e29636d8fb3204a54d285 # Parent 6d11c7a812087279c2b755f071aeccc71a13c5d4 patch 8.2.3379: crash when using NULL job Commit: https://github.com/vim/vim/commit/271906bc067a8f25422016665001d2e44cf618e2 Author: Bram Moolenaar Date: Sat Aug 28 12:30:12 2021 +0200 patch 8.2.3379: crash when using NULL job Problem: Crash when using NULL job. Solution: Copy static string into buffer. (issue https://github.com/vim/vim/issues/8260) diff --git a/src/job.c b/src/job.c --- a/src/job.c +++ b/src/job.c @@ -1983,7 +1983,10 @@ job_to_string_buf(typval_T *varp, char_u 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 --- 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 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3379, +/**/ 3378, /**/ 3377,