Skip to content

Commit 839fd11

Browse files
committed
patch 7.4.1503
Problem: Crash when using ch_getjob(). (Damien) Solution: Check for a NULL job.
1 parent 99ef062 commit 839fd11

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/eval.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15249,6 +15249,7 @@ f_job_start(typval_T *argvars UNUSED, typval_T *rettv)
1524915249
#endif
1525015250

1525115251
#ifdef FEAT_CHANNEL
15252+
/* If the channel is reading from a buffer, write lines now. */
1525215253
channel_write_in(job->jv_channel);
1525315254
#endif
1525415255

@@ -22601,7 +22602,11 @@ get_tv_string_buf_chk(typval_T *varp, char_u *buf)
2260122602
#ifdef FEAT_JOB
2260222603
{
2260322604
job_T *job = varp->vval.v_job;
22604-
char *status = job->jv_status == JOB_FAILED ? "fail"
22605+
char *status;
22606+
22607+
if (job == NULL)
22608+
return (char_u *)"no process";
22609+
status = job->jv_status == JOB_FAILED ? "fail"
2260522610
: job->jv_status == JOB_ENDED ? "dead"
2260622611
: "run";
2260722612
# ifdef UNIX

src/testdir/test_channel.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ func s:communicate(port)
108108
call assert_false(1, "Can't open channel")
109109
return
110110
endif
111+
if has('job')
112+
" check that no job is handled correctly
113+
call assert_equal('no process', string(ch_getjob(handle)))
114+
endif
111115

112116
" Simple string request and reply.
113117
call assert_equal('got it', ch_evalexpr(handle, 'hello!'))

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static char *(features[]) =
743743

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1503,
746748
/**/
747749
1502,
748750
/**/

0 commit comments

Comments
 (0)