diff src/ex_cmds.c @ 18221:d27060eba45f v8.1.2105

patch 8.1.2105: MS-Windows: system() may crash Commit: https://github.com/vim/vim/commit/2886dccebaec2da55e5a99bd88d44ae4217dee6e Author: Bram Moolenaar <Bram@vim.org> Date: Tue Oct 1 12:10:25 2019 +0200 patch 8.1.2105: MS-Windows: system() may crash Problem: MS-Windows: system() may crash. Solution: Do not use "itmp" when it is NULL. (Yasuhiro Matsumoto, closes #5005)
author Bram Moolenaar <Bram@vim.org>
date Tue, 01 Oct 2019 12:15:03 +0200
parents a81f0c936112
children d0dfb3b0fe31
line wrap: on
line diff
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1778,28 +1778,30 @@ make_filter_cmd(
     }
     else
     {
-	char_u	*p;
-
-	/*
-	 * If there is a pipe, we have to put the '<' in front of it.
-	 * Don't do this when 'shellquote' is not empty, otherwise the
-	 * redirection would be inside the quotes.
-	 */
-	if (*p_shq == NUL)
+	STRCPY(buf, cmd);
+	if (itmp != NULL)
 	{
-	    p = find_pipe(buf);
-	    if (p != NULL)
-		*p = NUL;
-	}
-	STRCAT(buf, " <");	/* " < " causes problems on Amiga */
-	STRCAT(buf, itmp);
-	if (*p_shq == NUL)
-	{
-	    p = find_pipe(cmd);
-	    if (p != NULL)
+	    char_u	*p;
+
+	    // If there is a pipe, we have to put the '<' in front of it.
+	    // Don't do this when 'shellquote' is not empty, otherwise the
+	    // redirection would be inside the quotes.
+	    if (*p_shq == NUL)
 	    {
-		STRCAT(buf, " ");   /* insert a space before the '|' for DOS */
-		STRCAT(buf, p);
+		p = find_pipe(buf);
+		if (p != NULL)
+		    *p = NUL;
+	    }
+	    STRCAT(buf, " <");	// " < " causes problems on Amiga
+	    STRCAT(buf, itmp);
+	    if (*p_shq == NUL)
+	    {
+		p = find_pipe(cmd);
+		if (p != NULL)
+		{
+		    STRCAT(buf, " ");  // insert a space before the '|' for DOS
+		    STRCAT(buf, p);
+		}
 	    }
 	}
     }