summaryrefslogtreecommitdiff
path: root/cppuhelper/source/bootstrap.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-09-25 08:59:28 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2017-09-27 06:24:24 +0200
commitd32506e9f4ea604532bf5f4ba8a302b652aeaaa1 (patch)
tree2bd33f7917bd76d18f998eea531e4bdaa7d7eb54 /cppuhelper/source/bootstrap.cxx
parent892c719fffa06de4c7aeab497326cad7bae9e5c6 (diff)
cppuhelper_detail_findSofficePath: use Unicode on Windows
On Windows, UTF-8 is never current locale encoding; so using 8-bit strings will always fail for paths containing characters outside of current codepage. Also fix leaks caused by failing to release its result: previously it could return either result of getenv (that shouldn't get freed), or an allocated string, but never got freed; now the result is always allocated and properly freed. Change-Id: I8b255dea20040eec0572de2b34280749fe8f071c Reviewed-on: https://gerrit.libreoffice.org/42743 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'cppuhelper/source/bootstrap.cxx')
-rw-r--r--cppuhelper/source/bootstrap.cxx13
1 files changed, 10 insertions, 3 deletions
diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx
index 55a0d244b724..923d0e925795 100644
--- a/cppuhelper/source/bootstrap.cxx
+++ b/cppuhelper/source/bootstrap.cxx
@@ -87,21 +87,28 @@ Reference< XComponentContext > SAL_CALL bootstrap()
try
{
- char const * p1 = cppuhelper_detail_findSofficePath();
+ auto* p1 = cppuhelper_detail_findSofficePath();
if (p1 == nullptr) {
throw BootstrapException(
"no soffice installation found!");
}
rtl::OUString p2;
- if (!rtl_convertStringToUString(
+#if defined(_WIN32)
+ p2 = SAL_U(p1);
+ free(p1);
+#else
+ bool bOk = rtl_convertStringToUString(
&p2.pData, p1, std::strlen(p1), osl_getThreadTextEncoding(),
(RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
- RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR));
+ free(p1);
+ if (!bOk)
{
throw BootstrapException(
"bad characters in soffice installation path!");
}
+#endif
OUString path;
if (osl::FileBase::getFileURLFromSystemPath(p2, path) !=
osl::FileBase::E_None)