Skip to content

Commit 42f652f

Browse files
committed
patch 8.0.1617: Win32: :shell command in the GUI crashes
Problem: Win32: :shell command in the GUI crashes. Solution: Handle the situation that "cmd" is NULL. (Yasuhiro Matsumoto, closes #2721)
1 parent f05fa37 commit 42f652f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/os_win32.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4800,15 +4800,25 @@ mch_call_shell_terminal(
48004800
aco_save_T aco;
48014801
oparg_T oa; /* operator arguments */
48024802

4803-
cmdlen = STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10;
4804-
4803+
if (cmd == NULL)
4804+
cmdlen = STRLEN(p_sh) + 1;
4805+
else
4806+
cmdlen = STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10;
48054807
newcmd = lalloc(cmdlen, TRUE);
48064808
if (newcmd == NULL)
48074809
return 255;
4808-
vim_snprintf((char *)newcmd, cmdlen, "%s %s %s", p_sh, p_shcf, cmd);
4810+
if (cmd == NULL)
4811+
{
4812+
STRCPY(newcmd, p_sh);
4813+
ch_log(NULL, "starting terminal to run a shell");
4814+
}
4815+
else
4816+
{
4817+
vim_snprintf((char *)newcmd, cmdlen, "%s %s %s", p_sh, p_shcf, cmd);
4818+
ch_log(NULL, "starting terminal for system command '%s'", cmd);
4819+
}
48094820

48104821
init_job_options(&opt);
4811-
ch_log(NULL, "starting terminal for system command '%s'", cmd);
48124822

48134823
argvar[0].v_type = VAR_STRING;
48144824
argvar[0].vval.v_string = newcmd;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ static char *(features[]) =
766766

767767
static int included_patches[] =
768768
{ /* Add new patch number below this line */
769+
/**/
770+
1617,
769771
/**/
770772
1616,
771773
/**/

0 commit comments

Comments
 (0)