mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.0.1429: crash when calling term_start() with empty argument
Problem: Crash when calling term_start() with empty argument. Solution: Check for invalid argument. (Yasuhiro Matsomoto, closes #2503) Fix memory leak.
This commit is contained in:
@@ -42,6 +42,7 @@
|
|||||||
* a job that uses 16 colors while Vim is using > 256.
|
* a job that uses 16 colors while Vim is using > 256.
|
||||||
* - in GUI vertical split causes problems. Cursor is flickering. (Hirohito
|
* - in GUI vertical split causes problems. Cursor is flickering. (Hirohito
|
||||||
* Higashi, 2017 Sep 19)
|
* Higashi, 2017 Sep 19)
|
||||||
|
* - Trigger TerminalOpen event? #2422 patch in #2484
|
||||||
* - Shift-Tab does not work.
|
* - Shift-Tab does not work.
|
||||||
* - after resizing windows overlap. (Boris Staletic, #2164)
|
* - after resizing windows overlap. (Boris Staletic, #2164)
|
||||||
* - Redirecting output does not work on MS-Windows, Test_terminal_redir_file()
|
* - Redirecting output does not work on MS-Windows, Test_terminal_redir_file()
|
||||||
@@ -62,6 +63,8 @@
|
|||||||
* - add test for giving error for invalid 'termsize' value.
|
* - add test for giving error for invalid 'termsize' value.
|
||||||
* - support minimal size when 'termsize' is "rows*cols".
|
* - support minimal size when 'termsize' is "rows*cols".
|
||||||
* - support minimal size when 'termsize' is empty?
|
* - support minimal size when 'termsize' is empty?
|
||||||
|
* - if the job in the terminal does not support the mouse, we can use the
|
||||||
|
* mouse in the Terminal window for copy/paste and scrolling.
|
||||||
* - GUI: when using tabs, focus in terminal, click on tab does not work.
|
* - GUI: when using tabs, focus in terminal, click on tab does not work.
|
||||||
* - GUI: when 'confirm' is set and trying to exit Vim, dialog offers to save
|
* - GUI: when 'confirm' is set and trying to exit Vim, dialog offers to save
|
||||||
* changes to "!shell".
|
* changes to "!shell".
|
||||||
@@ -69,8 +72,6 @@
|
|||||||
* - Redrawing is slow with Athena and Motif. Also other GUI? (Ramel Eshed)
|
* - Redrawing is slow with Athena and Motif. Also other GUI? (Ramel Eshed)
|
||||||
* - For the GUI fill termios with default values, perhaps like pangoterm:
|
* - For the GUI fill termios with default values, perhaps like pangoterm:
|
||||||
* http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134
|
* http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134
|
||||||
* - if the job in the terminal does not support the mouse, we can use the
|
|
||||||
* mouse in the Terminal window for copy/paste.
|
|
||||||
* - when 'encoding' is not utf-8, or the job is using another encoding, setup
|
* - when 'encoding' is not utf-8, or the job is using another encoding, setup
|
||||||
* conversions.
|
* conversions.
|
||||||
* - In the GUI use a terminal emulator for :!cmd. Make the height the same as
|
* - In the GUI use a terminal emulator for :!cmd. Make the height the same as
|
||||||
@@ -3388,28 +3389,36 @@ term_and_job_init(
|
|||||||
void *winpty_err;
|
void *winpty_err;
|
||||||
void *spawn_config = NULL;
|
void *spawn_config = NULL;
|
||||||
garray_T ga_cmd, ga_env;
|
garray_T ga_cmd, ga_env;
|
||||||
char_u *cmd;
|
char_u *cmd = NULL;
|
||||||
|
|
||||||
if (dyn_winpty_init(TRUE) == FAIL)
|
if (dyn_winpty_init(TRUE) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
ga_init2(&ga_cmd, (int)sizeof(char*), 20);
|
||||||
|
ga_init2(&ga_env, (int)sizeof(char*), 20);
|
||||||
|
|
||||||
if (argvar->v_type == VAR_STRING)
|
if (argvar->v_type == VAR_STRING)
|
||||||
cmd = argvar->vval.v_string;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
ga_init2(&ga_cmd, (int)sizeof(char*), 20);
|
cmd = argvar->vval.v_string;
|
||||||
|
}
|
||||||
|
else if (argvar->v_type == VAR_LIST)
|
||||||
|
{
|
||||||
if (win32_build_cmd(argvar->vval.v_list, &ga_cmd) == FAIL)
|
if (win32_build_cmd(argvar->vval.v_list, &ga_cmd) == FAIL)
|
||||||
goto failed;
|
goto failed;
|
||||||
cmd = ga_cmd.ga_data;
|
cmd = ga_cmd.ga_data;
|
||||||
}
|
}
|
||||||
|
if (cmd == NULL || *cmd == NUL)
|
||||||
|
{
|
||||||
|
EMSG(_(e_invarg));
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
|
|
||||||
cmd_wchar = enc_to_utf16(cmd, NULL);
|
cmd_wchar = enc_to_utf16(cmd, NULL);
|
||||||
|
ga_clear(&ga_cmd);
|
||||||
if (cmd_wchar == NULL)
|
if (cmd_wchar == NULL)
|
||||||
return FAIL;
|
goto failed;
|
||||||
if (opt->jo_cwd != NULL)
|
if (opt->jo_cwd != NULL)
|
||||||
cwd_wchar = enc_to_utf16(opt->jo_cwd, NULL);
|
cwd_wchar = enc_to_utf16(opt->jo_cwd, NULL);
|
||||||
|
|
||||||
ga_init2(&ga_env, (int)sizeof(char*), 20);
|
|
||||||
win32_build_env(opt->jo_env, &ga_env, TRUE);
|
win32_build_env(opt->jo_env, &ga_env, TRUE);
|
||||||
env_wchar = ga_env.ga_data;
|
env_wchar = ga_env.ga_data;
|
||||||
|
|
||||||
@@ -3490,6 +3499,7 @@ term_and_job_init(
|
|||||||
winpty_spawn_config_free(spawn_config);
|
winpty_spawn_config_free(spawn_config);
|
||||||
vim_free(cmd_wchar);
|
vim_free(cmd_wchar);
|
||||||
vim_free(cwd_wchar);
|
vim_free(cwd_wchar);
|
||||||
|
vim_free(env_wchar);
|
||||||
|
|
||||||
create_vterm(term, term->tl_rows, term->tl_cols);
|
create_vterm(term, term->tl_rows, term->tl_cols);
|
||||||
|
|
||||||
@@ -3511,9 +3521,8 @@ term_and_job_init(
|
|||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
if (argvar->v_type == VAR_LIST)
|
ga_clear(&ga_cmd);
|
||||||
vim_free(ga_cmd.ga_data);
|
ga_clear(&ga_env);
|
||||||
vim_free(ga_env.ga_data);
|
|
||||||
vim_free(cmd_wchar);
|
vim_free(cmd_wchar);
|
||||||
vim_free(cwd_wchar);
|
vim_free(cwd_wchar);
|
||||||
if (spawn_config != NULL)
|
if (spawn_config != NULL)
|
||||||
|
@@ -795,3 +795,14 @@ func Test_terminal_aucmd_on_close()
|
|||||||
au! repro
|
au! repro
|
||||||
delfunc Nop
|
delfunc Nop
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_terminal_term_start_empty_command()
|
||||||
|
let cmd = "call term_start('', {'curwin' : 1, 'term_finish' : 'close'})"
|
||||||
|
call assert_fails(cmd, 'E474')
|
||||||
|
let cmd = "call term_start('', {'curwin' : 1, 'term_finish' : 'close'})"
|
||||||
|
call assert_fails(cmd, 'E474')
|
||||||
|
let cmd = "call term_start({}, {'curwin' : 1, 'term_finish' : 'close'})"
|
||||||
|
call assert_fails(cmd, 'E474')
|
||||||
|
let cmd = "call term_start(0, {'curwin' : 1, 'term_finish' : 'close'})"
|
||||||
|
call assert_fails(cmd, 'E474')
|
||||||
|
endfunc
|
||||||
|
@@ -771,6 +771,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1429,
|
||||||
/**/
|
/**/
|
||||||
1428,
|
1428,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user