summaryrefslogtreecommitdiff
path: root/jvmfwk/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'jvmfwk/plugins')
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx6
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/util.cxx6
2 files changed, 7 insertions, 5 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)
{