diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-05-15 16:56:29 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-05-15 17:02:14 -0400 |
commit | 36fb600a9e98b1f41f53783977bbd7b96c254a1b (patch) | |
tree | b0470ce2a4e90f8f28418029054623d367c1f732 /src | |
parent | 3320b998165e82c5c2fa50ac82e8ae577215ab24 (diff) | |
download | rneovim-36fb600a9e98b1f41f53783977bbd7b96c254a1b.tar.gz rneovim-36fb600a9e98b1f41f53783977bbd7b96c254a1b.tar.bz2 rneovim-36fb600a9e98b1f41f53783977bbd7b96c254a1b.zip |
ex_terminal(): fix double-free
Closes #4554
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_docmd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 89c35a3c45..9a68a7c2a5 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9497,12 +9497,14 @@ static void ex_folddo(exarg_T *eap) static void ex_terminal(exarg_T *eap) { - // We will call termopen() with ['shell'] if not given a {cmd}. - char *name = (char *)p_sh; + char *name = (char *)p_sh; // Default to 'shell' if {cmd} is not given. + bool mustfree = false; char *lquote = "['"; char *rquote = "']"; + if (*eap->arg != NUL) { name = (char *)vim_strsave_escaped(eap->arg, (char_u *)"\"\\"); + mustfree = true; lquote = rquote = "\""; } @@ -9512,7 +9514,7 @@ static void ex_terminal(exarg_T *eap) eap->forceit==TRUE ? "!" : "", lquote, name, rquote); do_cmdline_cmd(ex_cmd); - if (name != (char *)p_sh) { + if (mustfree) { xfree(name); } } |