patch 8.1.2061: MS-Windows GUI: ":sh" crashes when trying to use a terminal
Problem: MS-Windows GUI: ":sh" crashes when trying to use a terminal.
Solution: Check for a NULL command. (Yasuhiro Matsumoto, closes #4958)
diff --git a/src/os_win32.c b/src/os_win32.c
index ae77e40..39b86d6 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -4657,12 +4657,14 @@
{
char_u *cmdbase = cmd;
- // Skip a leading quote and (.
- while (*cmdbase == '"' || *cmdbase == '(')
- ++cmdbase;
+ if (cmdbase != NULL)
+ // Skip a leading quote and (.
+ while (*cmdbase == '"' || *cmdbase == '(')
+ ++cmdbase;
// Check the command does not begin with "start "
- if (STRNICMP(cmdbase, "start", 5) != 0 || !VIM_ISWHITE(cmdbase[5]))
+ if (cmdbase == NULL
+ || STRNICMP(cmdbase, "start", 5) != 0 || !VIM_ISWHITE(cmdbase[5]))
{
// Use a terminal window to run the command in.
x = mch_call_shell_terminal(cmd, options);