summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-03-10 21:40:45 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-03-10 21:43:13 +0100
commiteee4dd746ea3fc09d51d008446ec82e3de456eed (patch)
treea883cc057f95a72ceb808ee5e4cbd8e6d98bb7f3 /stoc
parent8e9a7cac42d554402a6ead3a83ae8b7defc9247b (diff)
Fix memory leaks
Change-Id: If9f7dc4a28d5e005959f0d4a0a2ed317b699f292
Diffstat (limited to 'stoc')
-rw-r--r--stoc/source/javavm/javavm.cxx29
1 files changed, 5 insertions, 24 deletions
diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx
index ab72925cbefb..0e6577364fe2 100644
--- a/stoc/source/javavm/javavm.cxx
+++ b/stoc/source/javavm/javavm.cxx
@@ -657,23 +657,6 @@ JavaVirtualMachine::getSupportedServiceNames()
return serviceGetSupportedServiceNames();
}
-namespace {
-
-struct JavaInfoGuard: private boost::noncopyable {
- JavaInfoGuard(): info(nullptr) {}
-
- ~JavaInfoGuard() { delete info; }
-
- void clear() {
- delete info;
- info = nullptr;
- }
-
- JavaInfo * info;
-};
-
-}
-
css::uno::Any SAL_CALL
JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId)
throw (css::uno::RuntimeException, std::exception)
@@ -698,7 +681,7 @@ JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId)
if (aId != aProcessId)
return css::uno::Any();
- JavaInfoGuard info;
+ jfw::JavaInfoGuard info;
while (!m_xVirtualMachine.is()) // retry until successful
{
// This is the second attempt to create Java. m_bDontCreateJvm is
@@ -816,14 +799,14 @@ JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId)
//we search another one. As long as there is a javaldx, we should
//never come into this situation. javaldx checks always if the JRE
//still exist.
- JavaInfo * pJavaInfo = nullptr;
- if (JFW_E_NONE == jfw_getSelectedJRE(&pJavaInfo))
+ jfw::JavaInfoGuard pJavaInfo;
+ if (JFW_E_NONE == jfw_getSelectedJRE(&pJavaInfo.info))
{
sal_Bool bExist = sal_False;
- if (JFW_E_NONE == jfw_existJRE(pJavaInfo, &bExist))
+ if (JFW_E_NONE == jfw_existJRE(pJavaInfo.info, &bExist))
{
if (!bExist
- && ! (pJavaInfo->nRequirements & JFW_REQUIRE_NEEDRESTART))
+ && ! (pJavaInfo.info->nRequirements & JFW_REQUIRE_NEEDRESTART))
{
info.clear();
javaFrameworkError errFind = jfw_findAndSelectJRE(
@@ -836,8 +819,6 @@ JavaVirtualMachine::getJavaVM(css::uno::Sequence< sal_Int8 > const & rProcessId)
}
}
- delete pJavaInfo;
-
//Error: %PRODUCTNAME requires a Java
//runtime environment (JRE) to perform this task. The selected JRE
//is defective. Please select another version or install a new JRE