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( ...@@ -1574,6 +1574,7 @@ HRESULT WINAPI SHGetFolderPathW(
*pszPath = '\0'; *pszPath = '\0';
if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0])) if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
return E_INVALIDARG; return E_INVALIDARG;
szTemp[0] = 0;
type = CSIDL_Data[folder].type; type = CSIDL_Data[folder].type;
switch (type) switch (type)
{ {
...@@ -1620,15 +1621,13 @@ HRESULT WINAPI SHGetFolderPathW( ...@@ -1620,15 +1621,13 @@ HRESULT WINAPI SHGetFolderPathW(
break; break;
} }
if (FAILED(hr)) goto end;
/* Expand environment strings if necessary */ /* Expand environment strings if necessary */
if (*szTemp == '%') if (*szTemp == '%')
hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath); hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath);
else else
strcpyW(szBuildPath, szTemp); strcpyW(szBuildPath, szTemp);
/* Copy the path if it's available before we might return */ /* Copy the path if it's available before we might return */
if (pszPath) if (SUCCEEDED(hr) && pszPath)
strcpyW(pszPath, szBuildPath); strcpyW(pszPath, szBuildPath);
if (FAILED(hr)) goto end; 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