diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 69c95c63bd7..68b8d34f915 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -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;