Avoid copying invalid data on error.

This commit is contained in:
Juan Lang 2004-10-25 21:53:18 +00:00 committed by Alexandre Julliard
parent d9800f9fa9
commit 4a6a898e2d
1 changed files with 2 additions and 3 deletions

View File

@ -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(
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;