From e40320410374f8ce64a7b247e7548e2de63cce93 Mon Sep 17 00:00:00 2001 From: Silent Date: Sat, 3 Feb 2018 01:30:24 +0100 Subject: [PATCH] Simplify and fix memory leak in getSpecialFolderLocation Fixes #399, closes #4138 --- PowerEditor/src/Parameters.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index b6fdc9e78..288728265 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -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; }