summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2011-05-12 06:44:54 +0200
committerDavid Tardon <dtardon@redhat.com>2011-05-12 14:32:54 +0200
commitf9496177a4c942f2acc39a978a3cd65689f14d8d (patch)
tree9b1211976c8a4a95ca225179c9b261bc0dabd60f
parent067196fc0fd02dba18f41acc0cfd7e209713f9d8 (diff)
do not leak memory
-rw-r--r--comphelper/source/misc/componentmodule.cxx9
1 files changed, 8 insertions, 1 deletions
diff --git a/comphelper/source/misc/componentmodule.cxx b/comphelper/source/misc/componentmodule.cxx
index 56183da324..bb1cd73aa7 100644
--- a/comphelper/source/misc/componentmodule.cxx
+++ b/comphelper/source/misc/componentmodule.cxx
@@ -85,7 +85,7 @@ namespace comphelper
//-------------------------------------------------------------------------
OModule::OModule()
:m_nClients( 0 )
- ,m_pImpl( new OModuleImpl )
+ ,m_pImpl( 0 )
{
}
@@ -110,17 +110,24 @@ namespace comphelper
//--------------------------------------------------------------------------
void OModule::onFirstClient()
{
+ OSL_PRECOND( !m_pImpl, "called out of sequence" );
+ if ( !m_pImpl )
+ m_pImpl = new OModuleImpl;
}
//--------------------------------------------------------------------------
void OModule::onLastClient()
{
+ OSL_PRECOND( m_pImpl, "called out of sequence" );
+ delete m_pImpl;
+ m_pImpl = 0;
}
//--------------------------------------------------------------------------
void OModule::registerImplementation( const ComponentDescription& _rComp )
{
::osl::MutexGuard aGuard( m_aMutex );
+ OSL_PRECOND( m_pImpl, "not initialized properly" );
if ( !m_pImpl )
throw RuntimeException();