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 +,/;=[]"));
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;
}