From ef9449cd04748320ee45242feb53805eef07d44c Mon Sep 17 00:00:00 2001 From: Takeshi Abe Date: Fri, 11 Jul 2014 14:23:50 +0900 Subject: Avoid possible memory leaks in case of exceptions Change-Id: I5e302cf7ac784e1413c0539d0c967a3523f04ba0 --- cppuhelper/source/component_context.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'cppuhelper/source/component_context.cxx') 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 #include +#include + #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 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(pXComponentContext, SAL_NO_ACQUIRE); } -- cgit