diff --git a/ProcessUNIX.c b/ProcessUNIX.c
index 83838affcdf73eff36fce7f43258b6d4dc122263..2db12544ce29fd3322556d626d040c798e5cea16 100644
--- a/ProcessUNIX.c
+++ b/ProcessUNIX.c
@@ -418,9 +418,10 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
        parse it.  */
     newCommands[cp->NumberOfCommands] =
       kwsysSystem_Parse_CommandForUnix(*command, 0);
-    if(!newCommands[cp->NumberOfCommands])
+    if(!newCommands[cp->NumberOfCommands] ||
+       !newCommands[cp->NumberOfCommands][0])
       {
-      /* Out of memory.  */
+      /* Out of memory or no command parsed.  */
       free(newCommands);
       return 0;
       }