mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-30 01:04:57 +02:00
Simplify and fix memory leak in getSpecialFolderLocation
Fixes #399, closes #4138
This commit is contained in:
parent
bd0867ee62
commit
e403204103
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user