diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-10-17 18:51:52 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-10-17 18:51:52 +0200 |
commit | 218450ad5ea1f9f033b06754a29502d86100ff65 (patch) | |
tree | f66cdd5e4ed2cf2b58a3e0143093ad5c3e9f62eb /src/job.c | |
parent | 9668cc57a1e70c99163f90f58202e206d12f40c8 (diff) | |
download | vim-git-218450ad5ea1f9f033b06754a29502d86100ff65.tar.gz |
patch 8.2.1857: Vim9: using job_status() on an unused var gives an errorv8.2.1857
Problem: Vim9: using job_status() on an unused var gives an error.
Solution: Return "fail". (closes #7158)
Diffstat (limited to 'src/job.c')
-rw-r--r-- | src/job.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -1894,12 +1894,21 @@ f_job_start(typval_T *argvars, typval_T *rettv) void f_job_status(typval_T *argvars, typval_T *rettv) { - job_T *job = get_job_arg(&argvars[0]); - - if (job != NULL) + if (argvars[0].v_type == VAR_JOB && argvars[0].vval.v_job == NULL) { + // A job that never started returns "fail". rettv->v_type = VAR_STRING; - rettv->vval.v_string = vim_strsave((char_u *)job_status(job)); + rettv->vval.v_string = vim_strsave((char_u *)"fail"); + } + else + { + job_T *job = get_job_arg(&argvars[0]); + + if (job != NULL) + { + rettv->v_type = VAR_STRING; + rettv->vval.v_string = vim_strsave((char_u *)job_status(job)); + } } } |