]> granicus.if.org Git - vim/commitdiff
patch 8.2.3379: crash when using NULL job v8.2.3379
authorBram Moolenaar <Bram@vim.org>
Sat, 28 Aug 2021 10:30:12 +0000 (12:30 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 28 Aug 2021 10:30:12 +0000 (12:30 +0200)
Problem:    Crash when using NULL job.
Solution:   Copy static string into buffer. (issue #8260)

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

index 884bf64b853ff61786235acd0a70767cf10d739b..afa9972a766b909bd433a4d7685778b00435f16e 100644 (file)
--- 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";
index 783a41d2c330b06d25ae10ad12c6928a51c7a0a8..fa510c7bbcce300f0f01b29a52f526fbe0734baf 100644 (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 = {}
index a3f0a8db200030bfe670f6932e2455d4c3353c39..c2e07c668f62a9ad55aa6f4e92b4f9d6a4c991f5 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3379,
 /**/
     3378,
 /**/