Mercurial > vim
comparison src/terminal.c @ 19744:eb4887dd4b60 v8.2.0428
patch 8.2.0428: buffer name may leak
Commit: https://github.com/vim/vim/commit/d5bc32df207eae408263ae6ab737771365d0bca1
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 22 19:25:50 2020 +0100
patch 8.2.0428: buffer name may leak
Problem: Buffer name may leak.
Solution: Free the buffer name before overwriting it.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 22 Mar 2020 19:30:04 +0100 |
parents | 8514e8b7e661 |
children | d73d982499ae |
comparison
equal
deleted
inserted
replaced
19743:456d9eee3c81 | 19744:eb4887dd4b60 |
---|---|
463 else if (opt->jo_hidden || (flags & TERM_START_SYSTEM)) | 463 else if (opt->jo_hidden || (flags & TERM_START_SYSTEM)) |
464 { | 464 { |
465 buf_T *buf; | 465 buf_T *buf; |
466 | 466 |
467 // Create a new buffer without a window. Make it the current buffer for | 467 // Create a new buffer without a window. Make it the current buffer for |
468 // a moment to be able to do the initialisations. | 468 // a moment to be able to do the initializations. |
469 buf = buflist_new((char_u *)"", NULL, (linenr_T)0, | 469 buf = buflist_new((char_u *)"", NULL, (linenr_T)0, |
470 BLN_NEW | BLN_LISTED); | 470 BLN_NEW | BLN_LISTED); |
471 if (buf == NULL || ml_open(buf) == FAIL) | 471 if (buf == NULL || ml_open(buf) == FAIL) |
472 { | 472 { |
473 vim_free(term); | 473 vim_free(term); |
524 first_term = term; | 524 first_term = term; |
525 | 525 |
526 apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf); | 526 apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf); |
527 | 527 |
528 if (opt->jo_term_name != NULL) | 528 if (opt->jo_term_name != NULL) |
529 { | |
530 vim_free(curbuf->b_ffname); | |
529 curbuf->b_ffname = vim_strsave(opt->jo_term_name); | 531 curbuf->b_ffname = vim_strsave(opt->jo_term_name); |
532 } | |
530 else if (argv != NULL) | 533 else if (argv != NULL) |
534 { | |
535 vim_free(curbuf->b_ffname); | |
531 curbuf->b_ffname = vim_strsave((char_u *)"!system"); | 536 curbuf->b_ffname = vim_strsave((char_u *)"!system"); |
537 } | |
532 else | 538 else |
533 { | 539 { |
534 int i; | 540 int i; |
535 size_t len; | 541 size_t len; |
536 char_u *cmd, *p; | 542 char_u *cmd, *p; |
1981 if (term->tl_channel_closed) | 1987 if (term->tl_channel_closed) |
1982 cleanup_vterm(term); | 1988 cleanup_vterm(term); |
1983 redraw_buf_and_status_later(curbuf, NOT_VALID); | 1989 redraw_buf_and_status_later(curbuf, NOT_VALID); |
1984 #ifdef FEAT_PROP_POPUP | 1990 #ifdef FEAT_PROP_POPUP |
1985 if (WIN_IS_POPUP(curwin)) | 1991 if (WIN_IS_POPUP(curwin)) |
1986 redraw_win_later(curwin, NOT_VALID); | 1992 redraw_later(NOT_VALID); |
1987 #endif | 1993 #endif |
1988 } | 1994 } |
1989 | 1995 |
1990 /* | 1996 /* |
1991 * Get a key from the user with terminal mode mappings. | 1997 * Get a key from the user with terminal mode mappings. |
4319 init_default_colors(term, curwin); | 4325 init_default_colors(term, curwin); |
4320 vterm_state_set_default_colors( | 4326 vterm_state_set_default_colors( |
4321 vterm_obtain_state(term->tl_vterm), | 4327 vterm_obtain_state(term->tl_vterm), |
4322 &term->tl_default_color.fg, | 4328 &term->tl_default_color.fg, |
4323 &term->tl_default_color.bg); | 4329 &term->tl_default_color.bg); |
4330 | |
4331 redraw_later(NOT_VALID); | |
4324 } | 4332 } |
4325 | 4333 |
4326 /* | 4334 /* |
4327 * Return the text to show for the buffer name and status. | 4335 * Return the text to show for the buffer name and status. |
4328 */ | 4336 */ |