From 20043e3fa26dfe7574bc5e985455c7042e0e53f9 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 12 Nov 2016 12:21:31 +0000 Subject: coverity#1394296 Dereference before null check Change-Id: I143b7439b33695aa5bc4e32fd9386692eac37697 --- dbaccess/source/core/dataaccess/ModelImpl.cxx | 25 +++++++++++-------------- dbaccess/source/core/dataaccess/ModelImpl.hxx | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index e3d4a24ae2ad..f76875ac5445 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -400,7 +400,7 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< XComponentContext >& _r ,m_aContainer(4) ,m_aMacroMode( *this ) ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE ) - ,m_pDBContext( &_rDBContext ) + ,m_rDBContext( _rDBContext ) ,m_refCount(0) ,m_aEmbeddedMacros() ,m_bModificationLock( false ) @@ -434,7 +434,7 @@ ODatabaseModelImpl::ODatabaseModelImpl( ,m_aContainer(4) ,m_aMacroMode( *this ) ,m_nImposedMacroExecMode( MacroExecMode::NEVER_EXECUTE ) - ,m_pDBContext( &_rDBContext ) + ,m_rDBContext( _rDBContext ) ,m_refCount(0) ,m_aEmbeddedMacros() ,m_bModificationLock( false ) @@ -504,7 +504,7 @@ void ODatabaseModelImpl::impl_construct_nothrow() { DBG_UNHANDLED_EXCEPTION(); } - m_pDBContext->appendAtTerminateListener(*this); + m_rDBContext.appendAtTerminateListener(*this); } namespace @@ -982,11 +982,11 @@ void SAL_CALL ODatabaseModelImpl::release() if ( osl_atomic_decrement(&m_refCount) == 0 ) { acquire(); // prevent multiple releases - m_pDBContext->removeFromTerminateListener(*this); + m_rDBContext.removeFromTerminateListener(*this); dispose(); - m_pDBContext->storeTransientProperties(*this); - if ( m_pDBContext && !m_sDocumentURL.isEmpty() ) - m_pDBContext->revokeDatabaseDocument( *this ); + m_rDBContext.storeTransientProperties(*this); + if (!m_sDocumentURL.isEmpty()) + m_rDBContext.revokeDatabaseDocument(*this); delete this; } } @@ -1249,13 +1249,10 @@ void ODatabaseModelImpl::impl_switchToLogicalURL( const OUString& i_rDocumentURL m_sDocFileLocation = m_sDocumentURL; // register at the database context, or change registration - if ( m_pDBContext ) - { - if ( !sOldURL.isEmpty() ) - m_pDBContext->databaseDocumentURLChange( sOldURL, m_sDocumentURL ); - else - m_pDBContext->registerDatabaseDocument( *this ); - } + if (!sOldURL.isEmpty()) + m_rDBContext.databaseDocumentURLChange( sOldURL, m_sDocumentURL ); + else + m_rDBContext.registerDatabaseDocument( *this ); } OUString ODatabaseModelImpl::getObjectContainerStorageName( const ObjectType _eType ) diff --git a/dbaccess/source/core/dataaccess/ModelImpl.hxx b/dbaccess/source/core/dataaccess/ModelImpl.hxx index 32527923f0e1..8ed40c89b4b4 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.hxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.hxx @@ -183,7 +183,7 @@ private: SharedStorage m_xDocumentStorage; ::rtl::Reference< ::sfx2::DocumentStorageModifyListener > m_pStorageModifyListener; - ODatabaseContext* m_pDBContext; + ODatabaseContext& m_rDBContext; DocumentEventsData m_aDocumentEvents; ::comphelper::NamedValueCollection m_aMediaDescriptor; -- cgit