From 1d1acdef68071c3fbf34c12a2e81c67903e346df Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Fri, 16 Nov 2007 12:43:35 -0800 Subject: [PATCH] Dynamically allocate memory for executing an URL --- dlls/shell32/shlexec.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c index 1b891b3..c95d599 100644 --- a/dlls/shell32/shlexec.c +++ b/dlls/shell32/shlexec.c @@ -1407,9 +1407,11 @@ static UINT_PTR SHELL_execute_url( LPCWS { static const WCHAR wShell[] = {'\\','s','h','e','l','l','\\',0}; static const WCHAR wCommand[] = {'\\','c','o','m','m','a','n','d',0}; - WCHAR lpstrProtocol[256]; + UINT_PTR retval; + WCHAR *lpstrProtocol; LPCWSTR lpstrRes; INT iSize; + DWORD len; lpstrRes = strchrW(lpFile, ':'); if (lpstrRes) @@ -1419,6 +1421,12 @@ static UINT_PTR SHELL_execute_url( LPCWS TRACE("Got URL: %s\n", debugstr_w(lpFile)); /* Looking for ...protocol\shell\lpOperation\command */ + len = iSize + lstrlenW(wShell) + lstrlenW(wCommand) + 1; + if (psei->lpVerb) + len += lstrlenW(psei->lpVerb); + else + len += lstrlenW(wszOpen); + lpstrProtocol = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); memcpy(lpstrProtocol, lpFile, iSize*sizeof(WCHAR)); lpstrProtocol[iSize] = '\0'; strcatW(lpstrProtocol, wShell); @@ -1432,8 +1440,10 @@ static UINT_PTR SHELL_execute_url( LPCWS lpFile += iSize; while (*lpFile == ':') lpFile++; } - return execute_from_key(lpstrProtocol, lpFile, NULL, psei->lpParameters, - wcmd, execfunc, psei, psei_out); + retval = execute_from_key(lpstrProtocol, lpFile, NULL, psei->lpParameters, + wcmd, execfunc, psei, psei_out); + HeapFree(GetProcessHeap(), 0, lpstrProtocol); + return retval; } /************************************************************************* -- 1.4.1