Commit 4a6a898e authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

Avoid copying invalid data on error.

parent d9800f9f
......@@ -1574,6 +1574,7 @@ HRESULT WINAPI SHGetFolderPathW(
*pszPath = '\0';
if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
return E_INVALIDARG;
szTemp[0] = 0;
type = CSIDL_Data[folder].type;
switch (type)
{
......@@ -1620,15 +1621,13 @@ HRESULT WINAPI SHGetFolderPathW(
break;
}
if (FAILED(hr)) goto end;
/* Expand environment strings if necessary */
if (*szTemp == '%')
hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath);
else
strcpyW(szBuildPath, szTemp);
/* Copy the path if it's available before we might return */
if (pszPath)
if (SUCCEEDED(hr) && pszPath)
strcpyW(pszPath, szBuildPath);
if (FAILED(hr)) goto end;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment