comparison src/terminal.c @ 12367:7ae2b2c84ec5 v8.0.1063

patch 8.0.1063: Coverity warns for NULL check and array use commit https://github.com/vim/vim/commit/28550b74bb4373417eb6fbf132bd4211b7b92afa Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 5 23:31:01 2017 +0200 patch 8.0.1063: Coverity warns for NULL check and array use Problem: Coverity warns for NULL check and using variable pointer as an array. Solution: Remove the NULL check. Make "argvar" an array.
author Christian Brabandt <cb@256bit.org>
date Tue, 05 Sep 2017 23:45:04 +0200
parents 85fef6805d73
children d0cf7f71b95b
comparison
equal deleted inserted replaced
12366:1e2c608b8049 12367:7ae2b2c84ec5
460 * ":terminal": open a terminal window and execute a job in it. 460 * ":terminal": open a terminal window and execute a job in it.
461 */ 461 */
462 void 462 void
463 ex_terminal(exarg_T *eap) 463 ex_terminal(exarg_T *eap)
464 { 464 {
465 typval_T argvar; 465 typval_T argvar[2];
466 jobopt_T opt; 466 jobopt_T opt;
467 char_u *cmd; 467 char_u *cmd;
468 char_u *tofree = NULL; 468 char_u *tofree = NULL;
469 469
470 init_job_options(&opt); 470 init_job_options(&opt);
523 EMSG2(_("E181: Invalid attribute: %s"), cmd); 523 EMSG2(_("E181: Invalid attribute: %s"), cmd);
524 return; 524 return;
525 } 525 }
526 cmd = skipwhite(p); 526 cmd = skipwhite(p);
527 } 527 }
528 if (cmd == NULL || *cmd == NUL) 528 if (*cmd == NUL)
529 /* Make a copy, an autocommand may set 'shell'. */ 529 /* Make a copy of 'shell', an autocommand may change the option. */
530 tofree = cmd = vim_strsave(p_sh); 530 tofree = cmd = vim_strsave(p_sh);
531 531
532 if (eap->addr_count > 0) 532 if (eap->addr_count > 0)
533 { 533 {
534 /* Write lines from current buffer to the job. */ 534 /* Write lines from current buffer to the job. */
537 opt.jo_io_buf[PART_IN] = curbuf->b_fnum; 537 opt.jo_io_buf[PART_IN] = curbuf->b_fnum;
538 opt.jo_in_top = eap->line1; 538 opt.jo_in_top = eap->line1;
539 opt.jo_in_bot = eap->line2; 539 opt.jo_in_bot = eap->line2;
540 } 540 }
541 541
542 argvar.v_type = VAR_STRING; 542 argvar[0].v_type = VAR_STRING;
543 argvar.vval.v_string = cmd; 543 argvar[0].vval.v_string = cmd;
544 term_start(&argvar, &opt, eap->forceit); 544 argvar[1].v_type = VAR_UNKNOWN;
545 term_start(argvar, &opt, eap->forceit);
545 vim_free(tofree); 546 vim_free(tofree);
546 } 547 }
547 548
548 /* 549 /*
549 * Free the scrollback buffer for "term". 550 * Free the scrollback buffer for "term".
2884 if ((buf->b_term->tl_job->jv_channel == NULL 2885 if ((buf->b_term->tl_job->jv_channel == NULL
2885 || !buf->b_term->tl_job->jv_channel->ch_keep_open) 2886 || !buf->b_term->tl_job->jv_channel->ch_keep_open)
2886 && STRCMP(job_status(buf->b_term->tl_job), "dead") == 0) 2887 && STRCMP(job_status(buf->b_term->tl_job), "dead") == 0)
2887 { 2888 {
2888 /* The job is dead, keep reading channel I/O until the channel is 2889 /* The job is dead, keep reading channel I/O until the channel is
2889 * closed. */ 2890 * closed. buf->b_term may become NULL if the terminal was closed while
2891 * waiting. */
2890 ch_log(NULL, "term_wait(): waiting for channel to close"); 2892 ch_log(NULL, "term_wait(): waiting for channel to close");
2891 while (buf->b_term != NULL && !buf->b_term->tl_channel_closed) 2893 while (buf->b_term != NULL && !buf->b_term->tl_channel_closed)
2892 { 2894 {
2893 mch_check_messages(); 2895 mch_check_messages();
2894 parse_queued_messages(); 2896 parse_queued_messages();