Simplify and fix memory leak in getSpecialFolderLocation

Fixes #399, closes #4138
This commit is contained in:
Silent 2018-02-03 01:30:24 +01:00 committed by Don HO
parent bd0867ee62
commit e403204103
1 changed files with 7 additions and 7 deletions

View File

@ -946,15 +946,15 @@ bool NppParameters::reloadLang()
generic_string NppParameters::getSpecialFolderLocation(int folderKind)
{
ITEMIDLIST *pidl;
const HRESULT specialLocationResult = SHGetSpecialFolderLocation(NULL, folderKind, &pidl);
if (!SUCCEEDED( specialLocationResult))
return generic_string();
TCHAR path[MAX_PATH];
SHGetPathFromIDList(pidl, path);
const HRESULT specialLocationResult = SHGetFolderPath(nullptr, folderKind, nullptr, SHGFP_TYPE_CURRENT, path);
return path;
generic_string result;
if (SUCCEEDED(specialLocationResult))
{
result = path;
}
return result;
}