- npapi.h: Correct definitions of function pointer prototypes.
[reactos.git] / reactos / base / shell / cmd / cmd.c
index 0ef2ce2..968d6e5 100644 (file)
@@ -484,15 +484,24 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
 INT
 DoCommand(LPTSTR first, LPTSTR rest, PARSED_COMMAND *Cmd)
 {
-       TCHAR com[_tcslen(first) + _tcslen(rest) + 2];  /* full command line */
+       TCHAR *com;
        TCHAR *cp;
        LPTSTR param;   /* pointer to command's parameters */
        INT cl;
        LPCOMMAND cmdptr;
        BOOL nointernal = FALSE;
+       INT ret;
 
        TRACE ("DoCommand: (\'%s\' \'%s\')\n", debugstr_aw(first), debugstr_aw(rest));
 
+       /* full command line */
+       com = cmd_alloc((_tcslen(first) + _tcslen(rest) + 2) * sizeof(TCHAR));
+       if (com == NULL)
+       {
+               error_out_of_memory();
+               return 1;
+       }
+
        /* If present in the first word, these characters end the name of an
         * internal command and become the beginning of its parameters. */
        cp = first + _tcscspn(first, _T("\t +,/;=[]"));
@@ -526,11 +535,15 @@ DoCommand(LPTSTR first, LPTSTR rest, PARSED_COMMAND *Cmd)
                        if (_tcsicmp(cmdptr->name, _T("echo")) != 0)
                                while (_istspace(*param))
                                        param++;
-                       return cmdptr->func(param);
+                       ret = cmdptr->func(param);
+                       cmd_free(com);
+                       return ret;
                }
        }
 
-       return Execute(com, first, rest, Cmd);
+       ret = Execute(com, first, rest, Cmd);
+       cmd_free(com);
+       return ret;
 }