Avoid modifying command line string during argument count phase
This commit is contained in:
@@ -229,14 +229,31 @@ Shell::ParseCommand(IN PWCHAR CommandLine,
|
|||||||
|
|
||||||
/* Count the tokens to determine the size of the argument vector */
|
/* Count the tokens to determine the size of the argument vector */
|
||||||
TempLine = CommandLine;
|
TempLine = CommandLine;
|
||||||
Token = RTL::WideString::TokenizeWideString(TempLine, L" ", &SavePtr);
|
while(*TempLine != L'\0')
|
||||||
while(Token != NULLPTR)
|
|
||||||
{
|
{
|
||||||
|
/* Skip leading spaces */
|
||||||
|
while(*TempLine == L' ')
|
||||||
|
{
|
||||||
|
/* Move to the next character */
|
||||||
|
TempLine++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if the end of the string was reached */
|
||||||
|
if(*TempLine == L'\0')
|
||||||
|
{
|
||||||
|
/* End of the string, break the loop */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* One more argument found */
|
/* One more argument found */
|
||||||
ArgumentCount++;
|
ArgumentCount++;
|
||||||
|
|
||||||
/* Continue tokenizing */
|
/* Skip the characters of the token */
|
||||||
Token = RTL::WideString::TokenizeWideString(NULLPTR, L" ", &SavePtr);
|
while(*TempLine != L'\0' && *TempLine != L' ')
|
||||||
|
{
|
||||||
|
/* Move to the next character */
|
||||||
|
TempLine++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the command line was empty */
|
/* Check if the command line was empty */
|
||||||
|
|||||||
Reference in New Issue
Block a user