[0.4.11] [SHELL32] Fix 'Run' dialog crash (#1117)

CORE-15431 (2 of 2)
Running "%SYSTEMROOT%" sometimes crashed. This will fix it.
cherry picked from commit 0.4.12-dev-36-g
472787ffea
This commit is contained in:
Katayama Hirofumi MZ 2018-12-12 10:33:05 +09:00 committed by Joachim Henze
parent 5aea1c7118
commit 29f9c0433f

View file

@ -578,7 +578,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
if (wcschr(psz, L'%') != NULL) if (wcschr(psz, L'%') != NULL)
{ {
cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0); cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0) + 1;
pszExpanded = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, cchExpand * sizeof(WCHAR)); pszExpanded = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, cchExpand * sizeof(WCHAR));
if (!pszExpanded) if (!pszExpanded)
{ {
@ -604,7 +604,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
if (prfdp->lpstrDirectory) if (prfdp->lpstrDirectory)
pszStartDir = prfdp->lpstrDirectory; pszStartDir = prfdp->lpstrDirectory;
else if (prfdp->uFlags & RFF_CALCDIRECTORY) else if (prfdp->uFlags & RFF_CALCDIRECTORY)
pszStartDir = parent = RunDlg_GetParentDir(psz); pszStartDir = parent = RunDlg_GetParentDir(pszExpanded);
else else
pszStartDir = NULL; pszStartDir = NULL;
@ -640,8 +640,8 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
SECL_ALLOW_NONEXE))) SECL_ALLOW_NONEXE)))
{ {
/* Call again GetWindowText in case the contents of the edit box has changed? */ /* Call again GetWindowText in case the contents of the edit box has changed? */
GetWindowTextW(htxt, pszExpanded, ic + 1); GetWindowTextW(htxt, psz, ic + 1);
FillList(htxt, pszExpanded, ic + 2 + 1, FALSE); FillList(htxt, psz, ic + 2 + 1, FALSE);
EndDialog(hwnd, IDOK); EndDialog(hwnd, IDOK);
break; break;
} }