comparison src/terminal.c @ 15679:d8b4cbb14e1e v8.1.0847

patch 8.1.0847: may use terminal after it was cleaned up commit https://github.com/vim/vim/commit/9172d23d05f3f25996e03612654920b01158d734 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 29 23:06:54 2019 +0100 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.
author Bram Moolenaar <Bram@vim.org>
date Tue, 29 Jan 2019 23:15:05 +0100
parents 01890a3caefd
children a3e2e7948ee4
comparison
equal deleted inserted replaced
15678:de793242c37a 15679:d8b4cbb14e1e
1373 if (how == NULL || *how == NUL) 1373 if (how == NULL || *how == NUL)
1374 return FAIL; 1374 return FAIL;
1375 1375
1376 job_stop(buf->b_term->tl_job, NULL, how); 1376 job_stop(buf->b_term->tl_job, NULL, how);
1377 1377
1378 /* wait for up to a second for the job to die */ 1378 // wait for up to a second for the job to die
1379 for (count = 0; count < 100; ++count) 1379 for (count = 0; count < 100; ++count)
1380 { 1380 {
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
1382 if (!buf_valid(buf) 1384 if (!buf_valid(buf)
1383 || buf->b_term == NULL 1385 || buf->b_term == NULL
1384 || buf->b_term->tl_job == NULL) 1386 || buf->b_term->tl_job == NULL)
1385 return OK; 1387 return OK;
1386 1388 job = buf->b_term->tl_job;
1387 /* call job_status() to update jv_status */ 1389
1388 job_status(buf->b_term->tl_job); 1390 // Call job_status() to update jv_status. It may cause the job to be
1389 if (buf->b_term->tl_job->jv_status >= JOB_ENDED) 1391 // cleaned up but it won't be freed.
1392 job_status(job);
1393 if (job->jv_status >= JOB_ENDED)
1390 return OK; 1394 return OK;
1395
1391 ui_delay(10L, FALSE); 1396 ui_delay(10L, FALSE);
1392 mch_check_messages(); 1397 mch_check_messages();
1393 parse_queued_messages(); 1398 parse_queued_messages();
1394 } 1399 }
1395 return FAIL; 1400 return FAIL;