]> granicus.if.org Git - vim/commitdiff
patch 8.1.2105: MS-Windows: system() may crash v8.1.2105
authorBram Moolenaar <Bram@vim.org>
Tue, 1 Oct 2019 10:10:25 +0000 (12:10 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 1 Oct 2019 10:10:25 +0000 (12:10 +0200)
Problem:    MS-Windows: system() may crash.
Solution:   Do not use "itmp" when it is NULL. (Yasuhiro Matsumoto,
            closes #5005)

src/ex_cmds.c
src/version.c

index 9d58ab41a5f7378bd7dd0a47983f6c51c39f07b8..85e5be066df5ceaf1e4db8898d04a79310285cac 100644 (file)
@@ -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)
-       {
-           p = find_pipe(buf);
-           if (p != NULL)
-               *p = NUL;
-       }
-       STRCAT(buf, " <");      /* " < " causes problems on Amiga */
-       STRCAT(buf, itmp);
-       if (*p_shq == NUL)
+       STRCPY(buf, cmd);
+       if (itmp != NULL)
        {
-           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);
+               }
            }
        }
     }
index 29273b544f869b4c455c54f01a5e5b6155ac396a..229312bb287f4ad6673e3cfdb3890911fb4ef315 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2105,
 /**/
     2104,
 /**/