]> granicus.if.org Git - vim/commitdiff
patch 8.1.0847: may use terminal after it was cleaned up v8.1.0847
authorBram Moolenaar <Bram@vim.org>
Tue, 29 Jan 2019 22:06:54 +0000 (23:06 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 29 Jan 2019 22:06:54 +0000 (23:06 +0100)
Problem:    May use terminal after it was cleaned up.
Solution:   Use the job pointer.

src/terminal.c
src/version.c

index 87530af2eff46f143b7e3eb847a148208b9d16c9..760591443842c196712643907339addc5aeb6b1a 100644 (file)
@@ -1375,19 +1375,24 @@ term_try_stop_job(buf_T *buf)
 
     job_stop(buf->b_term->tl_job, NULL, how);
 
-    /* wait for up to a second for the job to die */
+    // wait for up to a second for the job to die
     for (count = 0; count < 100; ++count)
     {
-       /* buffer, terminal and job may be cleaned up while waiting */
+       job_T *job;
+
+       // buffer, terminal and job may be cleaned up while waiting
        if (!buf_valid(buf)
                || buf->b_term == NULL
                || buf->b_term->tl_job == NULL)
            return OK;
+       job = buf->b_term->tl_job;
 
-       /* call job_status() to update jv_status */
-       job_status(buf->b_term->tl_job);
-       if (buf->b_term->tl_job->jv_status >= JOB_ENDED)
+       // Call job_status() to update jv_status. It may cause the job to be
+       // cleaned up but it won't be freed.
+       job_status(job);
+       if (job->jv_status >= JOB_ENDED)
            return OK;
+
        ui_delay(10L, FALSE);
        mch_check_messages();
        parse_queued_messages();
index f693b660e946280b6dd35f1f5994d882e6bd01b2..729f650174be63e0edcd9764c98ed28f76ef01aa 100644 (file)
@@ -783,6 +783,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    847,
 /**/
     846,
 /**/