summaryrefslogtreecommitdiff
path: root/cppuhelper/source/interfacecontainer.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/interfacecontainer.cxx
parent18258eb811d1b8ad10810925952b8e32228128c5 (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: I5e302cf7ac784e1413c0539d0c967a3523f04ba0
Diffstat (limited to 'cppuhelper/source/interfacecontainer.cxx')
-rw-r--r--cppuhelper/source/interfacecontainer.cxx13
1 files changed, 5 insertions, 8 deletions
diff --git a/cppuhelper/source/interfacecontainer.cxx b/cppuhelper/source/interfacecontainer.cxx
index 22f090b08d23..0a0e251e689a 100644
--- a/cppuhelper/source/interfacecontainer.cxx
+++ b/cppuhelper/source/interfacecontainer.cxx
@@ -25,6 +25,7 @@
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
+#include <boost/scoped_array.hpp>
#include <boost/unordered_map.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
@@ -455,7 +456,7 @@ sal_Int32 OMultiTypeInterfaceContainerHelper::removeInterface(
void OMultiTypeInterfaceContainerHelper::disposeAndClear( const EventObject & rEvt )
{
t_type2ptr::size_type nSize = 0;
- OInterfaceContainerHelper ** ppListenerContainers = NULL;
+ boost::scoped_array<OInterfaceContainerHelper *> ppListenerContainers;
{
::osl::MutexGuard aGuard( rMutex );
t_type2ptr * pMap = (t_type2ptr *)m_pMap;
@@ -463,7 +464,7 @@ void OMultiTypeInterfaceContainerHelper::disposeAndClear( const EventObject & rE
if( nSize )
{
typedef OInterfaceContainerHelper* ppp;
- ppListenerContainers = new ppp[nSize];
+ ppListenerContainers.reset(new ppp[nSize]);
//ppListenerContainers = new (ListenerContainer*)[nSize];
t_type2ptr::iterator iter = pMap->begin();
@@ -485,8 +486,6 @@ void OMultiTypeInterfaceContainerHelper::disposeAndClear( const EventObject & rE
if( ppListenerContainers[i] )
ppListenerContainers[i]->disposeAndClear( rEvt );
}
-
- delete [] ppListenerContainers;
}
void OMultiTypeInterfaceContainerHelper::clear()
@@ -631,7 +630,7 @@ sal_Int32 OMultiTypeInterfaceContainerHelperInt32::removeInterface(
void OMultiTypeInterfaceContainerHelperInt32::disposeAndClear( const EventObject & rEvt )
{
t_long2ptr::size_type nSize = 0;
- OInterfaceContainerHelper ** ppListenerContainers = NULL;
+ boost::scoped_array<OInterfaceContainerHelper *> ppListenerContainers;
{
::osl::MutexGuard aGuard( rMutex );
if (!m_pMap)
@@ -642,7 +641,7 @@ void OMultiTypeInterfaceContainerHelperInt32::disposeAndClear( const EventObject
if( nSize )
{
typedef OInterfaceContainerHelper* ppp;
- ppListenerContainers = new ppp[nSize];
+ ppListenerContainers.reset(new ppp[nSize]);
t_long2ptr::iterator iter = pMap->begin();
t_long2ptr::iterator end = pMap->end();
@@ -663,8 +662,6 @@ void OMultiTypeInterfaceContainerHelperInt32::disposeAndClear( const EventObject
if( ppListenerContainers[i] )
ppListenerContainers[i]->disposeAndClear( rEvt );
}
-
- delete [] ppListenerContainers;
}
void OMultiTypeInterfaceContainerHelperInt32::clear()