diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-04-22 16:06:07 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-04-22 17:45:40 +0200 |
commit | 8de1bf3674b5f5391ff1be229d99115107514877 (patch) | |
tree | bb0857cf844556380d2bf94b25e07878049b1f16 /sal | |
parent | 31486f92f9ec0c2446ad96a4e8228a15797b23ba (diff) |
Introduce sal::systools::CoTaskMemAllocated to use RAII for CoTaskMemFree
Change-Id: I5553138bfc8dd989e68b8bcc2be981746e8c1e84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150783
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/w32/security.cxx | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/sal/osl/w32/security.cxx b/sal/osl/w32/security.cxx index 21ed64a7862a..0e9bc96c9b78 100644 --- a/sal/osl/w32/security.cxx +++ b/sal/osl/w32/security.cxx @@ -25,6 +25,7 @@ #include <osl/diagnose.h> #include <osl/thread.h> #include <osl/file.h> +#include <systools/win32/comtools.hxx> #include <systools/win32/uwinapi.h> #include <sddl.h> #include <sal/macros.h> @@ -509,16 +510,14 @@ void SAL_CALL osl_unloadUserProfile(oslSecurity Security) static bool GetSpecialFolder(rtl_uString **strPath, REFKNOWNFOLDERID rFolder) { - bool bRet = false; - PWSTR PathW; + sal::systools::CoTaskMemAllocated<wchar_t> PathW; if (SUCCEEDED(SHGetKnownFolderPath(rFolder, KF_FLAG_CREATE, nullptr, &PathW))) { rtl_uString_newFromStr(strPath, o3tl::toU(PathW)); - CoTaskMemFree(PathW); - bRet = true; + return true; } - return bRet; + return false; } // We use LPCTSTR here, because we use it with SE_foo_NAME constants |