{
int i, afterlastspace, ignorespace, doexpand;
size_t len;
+ char* aNewCmdln;
/* missing threading init */
len = strlen(_acmdln);
+ /* Allocate a temporary buffer to be used instead of the original _acmdln parameter. */
+ aNewCmdln = strndup(_acmdln, len);
- while (_acmdln[i])
+ while (aNewCmdln[i])
{
- if (_acmdln[i] == '"')
+ if (aNewCmdln[i] == '"')
{
if(ignorespace)
{
ignorespace = 1;
doexpand = 0;
}
- memmove(_acmdln + i, _acmdln + i + 1, len - i);
+ memmove(aNewCmdln + i, aNewCmdln + i + 1, len - i);
len--;
continue;
}
- if (_acmdln[i] == ' ' && !ignorespace)
+ if (aNewCmdln[i] == ' ' && !ignorespace)
{
- aexpand(strndup(_acmdln + afterlastspace, i - afterlastspace), doexpand);
+ aexpand(strndup(aNewCmdln + afterlastspace, i - afterlastspace), doexpand);
i++;
- while (_acmdln[i]==' ')
+ while (aNewCmdln[i] == ' ')
i++;
afterlastspace=i;
doexpand = expand_wildcards;
}
}
- if (_acmdln[afterlastspace] != 0)
+ if (aNewCmdln[afterlastspace] != 0)
{
- aexpand(strndup(_acmdln+afterlastspace, i - afterlastspace), doexpand);
+ aexpand(strndup(aNewCmdln + afterlastspace, i - afterlastspace), doexpand);
}
+ /* Free the temporary buffer. */
+ free(aNewCmdln);
+
HeapValidate(GetProcessHeap(), 0, NULL);
*argc = __argc;
{
int i, afterlastspace, ignorespace, doexpand;
size_t len;
+ wchar_t* wNewCmdln;
/* missing threading init */
len = wcslen(_wcmdln);
- while (_wcmdln[i])
+ /* Allocate a temporary buffer to be used instead of the original _wcmdln parameter. */
+ wNewCmdln = wcsndup(_wcmdln, len);
+
+ while (wNewCmdln[i])
{
- if (_wcmdln[i] == L'"')
+ if (wNewCmdln[i] == L'"')
{
if(ignorespace)
{
ignorespace = 1;
doexpand = 0;
}
- memmove(_wcmdln + i, _wcmdln + i + 1, (len - i) * sizeof(wchar_t));
+ memmove(wNewCmdln + i, wNewCmdln + i + 1, (len - i) * sizeof(wchar_t));
len--;
continue;
}
- if (_wcmdln[i] == L' ' && !ignorespace)
+ if (wNewCmdln[i] == L' ' && !ignorespace)
{
- wexpand(wcsndup(_wcmdln + afterlastspace, i - afterlastspace), doexpand);
+ wexpand(wcsndup(wNewCmdln + afterlastspace, i - afterlastspace), doexpand);
i++;
- while (_wcmdln[i]==L' ')
+ while (wNewCmdln[i] == L' ')
i++;
afterlastspace=i;
doexpand = expand_wildcards;
}
}
- if (_wcmdln[afterlastspace] != 0)
+ if (wNewCmdln[afterlastspace] != 0)
{
- wexpand(wcsndup(_wcmdln+afterlastspace, i - afterlastspace), doexpand);
+ wexpand(wcsndup(wNewCmdln + afterlastspace, i - afterlastspace), doexpand);
}
+ /* Free the temporary buffer. */
+ free(wNewCmdln);
+
HeapValidate(GetProcessHeap(), 0, NULL);
*argc = __argc;