Skip to content

Commit 9172d23

Browse files
committed
patch 8.1.0847: may use terminal after it was cleaned up
Problem: May use terminal after it was cleaned up. Solution: Use the job pointer.
1 parent 39536dd commit 9172d23

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/terminal.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,19 +1375,24 @@ term_try_stop_job(buf_T *buf)
13751375

13761376
job_stop(buf->b_term->tl_job, NULL, how);
13771377

1378-
/* wait for up to a second for the job to die */
1378+
// wait for up to a second for the job to die
13791379
for (count = 0; count < 100; ++count)
13801380
{
1381-
/* buffer, terminal and job may be cleaned up while waiting */
1381+
job_T *job;
1382+
1383+
// buffer, terminal and job may be cleaned up while waiting
13821384
if (!buf_valid(buf)
13831385
|| buf->b_term == NULL
13841386
|| buf->b_term->tl_job == NULL)
13851387
return OK;
1388+
job = buf->b_term->tl_job;
13861389

1387-
/* call job_status() to update jv_status */
1388-
job_status(buf->b_term->tl_job);
1389-
if (buf->b_term->tl_job->jv_status >= JOB_ENDED)
1390+
// Call job_status() to update jv_status. It may cause the job to be
1391+
// cleaned up but it won't be freed.
1392+
job_status(job);
1393+
if (job->jv_status >= JOB_ENDED)
13901394
return OK;
1395+
13911396
ui_delay(10L, FALSE);
13921397
mch_check_messages();
13931398
parse_queued_messages();

src/version.c

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

784784
static int included_patches[] =
785785
{ /* Add new patch number below this line */
786+
/**/
787+
847,
786788
/**/
787789
846,
788790
/**/

0 commit comments

Comments
 (0)