]> granicus.if.org Git - vim/commitdiff
patch 8.0.1617: Win32: :shell command in the GUI crashes v8.0.1617
authorBram Moolenaar <Bram@vim.org>
Mon, 19 Mar 2018 20:44:37 +0000 (21:44 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 19 Mar 2018 20:44:37 +0000 (21:44 +0100)
Problem:    Win32: :shell command in the GUI crashes.
Solution:   Handle the situation that "cmd" is NULL. (Yasuhiro Matsumoto,
            closes #2721)

src/os_win32.c
src/version.c

index c3f3f687e3d69bfa65865b4d45b0897bdc20b6ab..b70a0025d1d2d02cd51fc634d2e6b322f104f653 100644 (file)
@@ -4800,15 +4800,25 @@ mch_call_shell_terminal(
     aco_save_T aco;
     oparg_T    oa;             /* operator arguments */
 
-    cmdlen = STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10;
-
+    if (cmd == NULL)
+       cmdlen = STRLEN(p_sh) + 1;
+    else
+       cmdlen = STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10;
     newcmd = lalloc(cmdlen, TRUE);
     if (newcmd == NULL)
        return 255;
-    vim_snprintf((char *)newcmd, cmdlen, "%s %s %s", p_sh, p_shcf, cmd);
+    if (cmd == NULL)
+    {
+       STRCPY(newcmd, p_sh);
+       ch_log(NULL, "starting terminal to run a shell");
+    }
+    else
+    {
+       vim_snprintf((char *)newcmd, cmdlen, "%s %s %s", p_sh, p_shcf, cmd);
+       ch_log(NULL, "starting terminal for system command '%s'", cmd);
+    }
 
     init_job_options(&opt);
-    ch_log(NULL, "starting terminal for system command '%s'", cmd);
 
     argvar[0].v_type = VAR_STRING;
     argvar[0].vval.v_string = newcmd;
index 58c4e89848653dc8023289dbb52f092bdf67d573..92ca63ad12f4b58ab56fe3d63bc325f7b4db23fa 100644 (file)
@@ -766,6 +766,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1617,
 /**/
     1616,
 /**/