summaryrefslogtreecommitdiff
path: root/cppuhelper/source/component_context.cxx
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-07-11 14:23:50 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-07-12 07:57:32 +0900
commitef9449cd04748320ee45242feb53805eef07d44c (patch)
treec8e8d0fe9021d00b9959ea91d1e60a453254e5a7 /cppuhelper/source/component_context.cxx
parent18258eb811d1b8ad10810925952b8e32228128c5 (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: I5e302cf7ac784e1413c0539d0c967a3523f04ba0
Diffstat (limited to 'cppuhelper/source/component_context.cxx')
-rw-r--r--cppuhelper/source/component_context.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx
index dc8944af5b79..16642e9133fb 100644
--- a/cppuhelper/source/component_context.cxx
+++ b/cppuhelper/source/component_context.cxx
@@ -54,6 +54,8 @@
#include <com/sun/star/uno/DeploymentException.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
+#include <boost/scoped_array.hpp>
+
#define SMGR_SINGLETON "/singletons/com.sun.star.lang.theServiceManager"
#define TDMGR_SINGLETON "/singletons/com.sun.star.reflection.theTypeDescriptionManager"
#define AC_SINGLETON "/singletons/com.sun.star.security.theAccessController"
@@ -844,7 +846,7 @@ Reference< XComponentContext > SAL_CALL createComponentContext(
uno::Mapping curr2source(curr_env, source_env);
uno::Mapping source2curr(source_env, curr_env);
- ContextEntry_Init * mapped_entries = new ContextEntry_Init[nEntries];
+ boost::scoped_array<ContextEntry_Init> mapped_entries(new ContextEntry_Init[nEntries]);
for (sal_Int32 nPos = 0; nPos < nEntries; ++ nPos)
{
mapped_entries[nPos].bLateInitService = pEntries[nPos].bLateInitService;
@@ -858,8 +860,8 @@ Reference< XComponentContext > SAL_CALL createComponentContext(
void * mapped_delegate = curr2source.mapInterface(xDelegate.get(), ::getCppuType(&xDelegate));
XComponentContext * pXComponentContext = NULL;
- source_env.invoke(s_createComponentContext_v, mapped_entries, nEntries, mapped_delegate, &pXComponentContext, &source2curr);
- delete[] mapped_entries;
+ source_env.invoke(s_createComponentContext_v, mapped_entries.get(), nEntries, mapped_delegate, &pXComponentContext, &source2curr);
+ mapped_entries.reset();
return Reference<XComponentContext>(pXComponentContext, SAL_NO_ACQUIRE);
}