Mercurial > vim
changeset 12124:4e9c14cb1f5d v8.0.0942
patch 8.0.0942: using freed memory with ":terminal"
commit https://github.com/vim/vim/commit/4fa1019f8026cb383423fb4086cba7e308591e18
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 14 22:56:27 2017 +0200
patch 8.0.0942: using freed memory with ":terminal"
Problem: Using freed memory with ":terminal" if an autocommand changes
'shell' when splitting the window. (Marius Gedminas)
Solution: Make a copy of 'shell'. (closes #1974)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 14 Aug 2017 23:00:04 +0200 |
parents | 8988a0c73f5b |
children | 9dc391a1f787 |
files | src/terminal.c src/version.c |
diffstat | 2 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/terminal.c +++ b/src/terminal.c @@ -392,7 +392,8 @@ term_start(typval_T *argvar, jobopt_T *o setup_job_options(opt, term->tl_rows, term->tl_cols); /* System dependent: setup the vterm and start the job in it. */ - if (term_and_job_init(term, term->tl_rows, term->tl_cols, argvar, opt) == OK) + if (term_and_job_init(term, term->tl_rows, term->tl_cols, argvar, opt) + == OK) { /* Get and remember the size we ended up with. Update the pty. */ vterm_get_size(term->tl_vterm, &term->tl_rows, &term->tl_cols); @@ -434,6 +435,7 @@ ex_terminal(exarg_T *eap) typval_T argvar; jobopt_T opt; char_u *cmd; + char_u *tofree = NULL; init_job_options(&opt); @@ -462,7 +464,8 @@ ex_terminal(exarg_T *eap) cmd = skipwhite(p); } if (cmd == NULL || *cmd == NUL) - cmd = p_sh; + /* Make a copy, an autocommand may set 'shell'. */ + tofree = cmd = vim_strsave(p_sh); if (eap->addr_count == 2) { @@ -480,6 +483,7 @@ ex_terminal(exarg_T *eap) argvar.v_type = VAR_STRING; argvar.vval.v_string = cmd; term_start(&argvar, &opt, eap->forceit); + vim_free(tofree); } /*