Skip to content

Commit

Permalink
Simplify and fix memory leak in getSpecialFolderLocation
Browse files Browse the repository at this point in the history
Fixes #399, closes #4138
  • Loading branch information
CookiePLMonster authored and donho committed Feb 19, 2018
1 parent bd0867e commit e403204
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions PowerEditor/src/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit e403204

Please sign in to comment.