From 29f9c0433f6dfce887b808ac8e3c190c7bd18a5b Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 12 Dec 2018 10:33:05 +0900 Subject: [PATCH] [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 472787ffea068447d9ff529f836ceff2a8a04c31 --- dll/win32/shell32/dialogs/dialogs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dll/win32/shell32/dialogs/dialogs.cpp b/dll/win32/shell32/dialogs/dialogs.cpp index fc23284a137..f2fce61fd90 100644 --- a/dll/win32/shell32/dialogs/dialogs.cpp +++ b/dll/win32/shell32/dialogs/dialogs.cpp @@ -578,7 +578,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA if (wcschr(psz, L'%') != NULL) { - cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0); + cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0) + 1; pszExpanded = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, cchExpand * sizeof(WCHAR)); if (!pszExpanded) { @@ -604,7 +604,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA if (prfdp->lpstrDirectory) pszStartDir = prfdp->lpstrDirectory; else if (prfdp->uFlags & RFF_CALCDIRECTORY) - pszStartDir = parent = RunDlg_GetParentDir(psz); + pszStartDir = parent = RunDlg_GetParentDir(pszExpanded); else pszStartDir = NULL; @@ -640,8 +640,8 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA SECL_ALLOW_NONEXE))) { /* Call again GetWindowText in case the contents of the edit box has changed? */ - GetWindowTextW(htxt, pszExpanded, ic + 1); - FillList(htxt, pszExpanded, ic + 2 + 1, FALSE); + GetWindowTextW(htxt, psz, ic + 1); + FillList(htxt, psz, ic + 2 + 1, FALSE); EndDialog(hwnd, IDOK); break; }