summaryrefslogtreecommitdiff
path: root/jvmfwk
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-09-26 11:28:57 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2017-09-30 11:23:41 +0200
commit362a21d3a129b90149f6ef645c127f5e86e0ba61 (patch)
tree8583cb29b33de56e4489cb8950d2714a1fb2957e /jvmfwk
parent81ce629c9e8a4fc26ded9d49157e3f3263991e03 (diff)
Use explicit function names for fooA/fooW WinAPI; prefer fooW
We should only use generic foo function name when it takes params that are also dependent on UNICODE define, like LoadCursor( nullptr, IDC_ARROW ) where IDC_ARROW is defined in MSVC headers synchronised with LoadCursor definition. We should always use Unicode API for any file paths operations, because otherwise we will get "?" for any character in path that is not in current non-unicode codepage, which will result in failed file operations. Change-Id: I3a7f453ca0f893002d8a9764318919709fd8b633 Reviewed-on: https://gerrit.libreoffice.org/42935 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'jvmfwk')
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx6
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/util.cxx6
-rw-r--r--jvmfwk/source/fwkutil.cxx14
3 files changed, 14 insertions, 12 deletions
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index 5d28e0240b58..7a9cefd78f34 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -485,8 +485,7 @@ static void load_msvcr(OUString const & jvm_dll, OUStringLiteral msvcr)
}
if (LoadLibraryW(
- reinterpret_cast<wchar_t const *>(
- OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr())))
+ SAL_W(OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr())))
return;
// Then check if msvcr71.dll is in the parent folder of where
@@ -498,8 +497,7 @@ static void load_msvcr(OUString const & jvm_dll, OUStringLiteral msvcr)
return;
LoadLibraryW(
- reinterpret_cast<wchar_t const *>(
- OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr()));
+ SAL_W(OUString(jvm_dll.copy(0, slash+1) + msvcr).getStr()));
}
// Check if the jvm DLL imports msvcr71.dll, and in that case try
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index f1bf45816af6..7513716d4f90 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -631,7 +631,11 @@ bool getJavaInfoFromRegistry(const wchar_t* szRegKey,
// Find out how long the string for JavaHome is and allocate memory to hold the path
if( RegQueryValueExW(hKey, L"JavaHome", nullptr, &dwType, nullptr, &dwTmpPathLen)== ERROR_SUCCESS)
{
- unsigned char* szTmpPath= static_cast<unsigned char *>(malloc( dwTmpPathLen));
+ unsigned char* szTmpPath= static_cast<unsigned char *>(malloc(dwTmpPathLen+sizeof(sal_Unicode)));
+ // According to https://msdn.microsoft.com/en-us/ms724911, the application should ensure
+ // that the string is properly terminated before using it
+ for (DWORD i = 0; i < sizeof(sal_Unicode); ++i)
+ szTmpPath[dwTmpPathLen + i] = 0;
// Get the path for the runtime lib
if(RegQueryValueExW(hKey, L"JavaHome", nullptr, &dwType, szTmpPath, &dwTmpPathLen) == ERROR_SUCCESS)
{
diff --git a/jvmfwk/source/fwkutil.cxx b/jvmfwk/source/fwkutil.cxx
index fbb885b1d0c2..95fa21503bc0 100644
--- a/jvmfwk/source/fwkutil.cxx
+++ b/jvmfwk/source/fwkutil.cxx
@@ -66,18 +66,19 @@ bool isAccessibilitySupportDesired()
#ifdef _WIN32
bool retVal = false;
HKEY hKey = nullptr;
- if (RegOpenKeyEx(HKEY_CURRENT_USER,
- "Software\\LibreOffice\\Accessibility\\AtToolSupport",
- 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+ if (RegOpenKeyExA(HKEY_CURRENT_USER,
+ "Software\\LibreOffice\\Accessibility\\AtToolSupport",
+ 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
DWORD dwType = 0;
DWORD dwLen = 16;
unsigned char arData[16];
- if( RegQueryValueEx(hKey, "SupportAssistiveTechnology", nullptr, &dwType, arData,
- & dwLen)== ERROR_SUCCESS)
+ if( RegQueryValueExA(hKey, "SupportAssistiveTechnology", nullptr, &dwType, arData,
+ &dwLen)== ERROR_SUCCESS)
{
if (dwType == REG_SZ)
{
+ arData[std::min(dwLen, DWORD(15))] = 0;
if (strcmp(reinterpret_cast<char*>(arData), "true") == 0
|| strcmp(reinterpret_cast<char*>(arData), "1") == 0)
retVal = true;
@@ -98,9 +99,8 @@ bool isAccessibilitySupportDesired()
"jfw", "bad registry value " << unsigned(arData[0]));
}
}
+ RegCloseKey(hKey);
}
- RegCloseKey(hKey);
-
#elif defined UNX
// Java is no longer required for a11y - we use atk directly.
bool retVal = ::rtl::Bootstrap::get( "JFW_PLUGIN_FORCE_ACCESSIBILITY", sValue) && sValue == "1";