mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 19:21:38 +00:00
[EXPLORER] Allocate the string for expanded command line from heap
Addendum to 6fe704b
.
CORE-12973 CORE-17168
This commit is contained in:
parent
6fe704b0f0
commit
21b56d77c6
1 changed files with 24 additions and 4 deletions
|
@ -229,6 +229,7 @@ static BOOL ProcessRunKeys(HKEY hkRoot, LPCWSTR szKeyName, BOOL bDelete,
|
|||
|
||||
while (i > 0)
|
||||
{
|
||||
WCHAR *szCmdLineExp = NULL;
|
||||
DWORD cchValLength = cchMaxValue, cbDataLength = cbMaxCmdLine;
|
||||
DWORD type;
|
||||
|
||||
|
@ -266,18 +267,37 @@ static BOOL ProcessRunKeys(HKEY hkRoot, LPCWSTR szKeyName, BOOL bDelete,
|
|||
|
||||
if (type == REG_EXPAND_SZ)
|
||||
{
|
||||
WCHAR szCmdLineExp[MAX_PATH + 1] = L"\0";
|
||||
DWORD dwNumOfChars;
|
||||
|
||||
if (ExpandEnvironmentStringsW(szCmdLine, szCmdLineExp, _countof(szCmdLineExp)))
|
||||
StringCbCopyW(szCmdLine, cbMaxCmdLine, szCmdLineExp);
|
||||
dwNumOfChars = ExpandEnvironmentStringsW(szCmdLine, NULL, 0);
|
||||
if (dwNumOfChars)
|
||||
{
|
||||
szCmdLineExp = (WCHAR *)HeapAlloc(hProcessHeap, 0, dwNumOfChars * sizeof(*szCmdLineExp));
|
||||
|
||||
if (szCmdLineExp == NULL)
|
||||
{
|
||||
TRACE("Couldn't allocate memory for the commands to be executed\n");
|
||||
|
||||
res = ERROR_NOT_ENOUGH_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
|
||||
ExpandEnvironmentStringsW(szCmdLine, szCmdLineExp, dwNumOfChars);
|
||||
}
|
||||
}
|
||||
|
||||
res = runCmd(szCmdLine, NULL, bSynchronous, FALSE);
|
||||
res = runCmd(szCmdLineExp ? szCmdLineExp : szCmdLine, NULL, bSynchronous, FALSE);
|
||||
if (res == INVALID_RUNCMD_RETURN)
|
||||
{
|
||||
TRACE("Error running cmd #%lu (%lu)\n", i, GetLastError());
|
||||
}
|
||||
|
||||
if (szCmdLineExp != NULL)
|
||||
{
|
||||
HeapFree(hProcessHeap, 0, szCmdLineExp);
|
||||
szCmdLineExp = NULL;
|
||||
}
|
||||
|
||||
TRACE("Done processing cmd #%lu\n", i);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue