From 2877e5a9c7507acc9282e70323259b5c043dda0c Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 12 Mar 2015 18:16:57 +0100 Subject: package: PVS-Studio V595 'm_pData' pointer could be null ... just convert its explicitly deleted member to unique_ptr. Change-Id: I826257ff512632a2aedd53a7ce5e4bedf49c3cfe --- package/source/xstor/owriteablestream.cxx | 31 ++++++++++++++----------------- package/source/xstor/owriteablestream.hxx | 10 ++++------ 2 files changed, 18 insertions(+), 23 deletions(-) (limited to 'package') diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 31a99df4d141..cf20db3e4d38 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -1728,9 +1728,6 @@ OWriteStream::~OWriteStream() } } - if ( m_pData && m_pData->m_pTypeCollection ) - delete m_pData->m_pTypeCollection; - delete m_pData; } @@ -1922,11 +1919,11 @@ void SAL_CALL OWriteStream::release() throw() uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() throw( uno::RuntimeException, std::exception ) { - if ( m_pData->m_pTypeCollection == NULL ) + if (! m_pData->m_pTypeCollection) { ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() ); - if ( m_pData->m_pTypeCollection == NULL ) + if (! m_pData->m_pTypeCollection) { if ( m_bTransacted ) { @@ -1946,13 +1943,13 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() , cppu::UnoType::get() , cppu::UnoType::get()); - m_pData->m_pTypeCollection = new ::cppu::OTypeCollection + m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection ( cppu::UnoType::get() - , aTmpCollection.getTypes() ); + , aTmpCollection.getTypes())); } else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML ) { - m_pData->m_pTypeCollection = new ::cppu::OTypeCollection + m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection ( cppu::UnoType::get() , cppu::UnoType::get() , cppu::UnoType::get() @@ -1964,11 +1961,11 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() , cppu::UnoType::get() , cppu::UnoType::get() , cppu::UnoType::get() - , cppu::UnoType::get()); + , cppu::UnoType::get())); } else // if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP ) { - m_pData->m_pTypeCollection = new ::cppu::OTypeCollection + m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection ( cppu::UnoType::get() , cppu::UnoType::get() , cppu::UnoType::get() @@ -1979,14 +1976,14 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() , cppu::UnoType::get() , cppu::UnoType::get() , cppu::UnoType::get() - , cppu::UnoType::get()); + , cppu::UnoType::get())); } } else { if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE ) { - m_pData->m_pTypeCollection = new ::cppu::OTypeCollection + m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection ( cppu::UnoType::get() , cppu::UnoType::get() , cppu::UnoType::get() @@ -1996,11 +1993,11 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() , cppu::UnoType::get() , cppu::UnoType::get() , cppu::UnoType::get() - , cppu::UnoType::get()); + , cppu::UnoType::get())); } else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML ) { - m_pData->m_pTypeCollection = new ::cppu::OTypeCollection + m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection ( cppu::UnoType::get() , cppu::UnoType::get() , cppu::UnoType::get() @@ -2009,11 +2006,11 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() , cppu::UnoType::get() , cppu::UnoType::get() , cppu::UnoType::get() - , cppu::UnoType::get()); + , cppu::UnoType::get())); } else // if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP ) { - m_pData->m_pTypeCollection = new ::cppu::OTypeCollection + m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection ( cppu::UnoType::get() , cppu::UnoType::get() , cppu::UnoType::get() @@ -2021,7 +2018,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() , cppu::UnoType::get() , cppu::UnoType::get() , cppu::UnoType::get() - , cppu::UnoType::get()); + , cppu::UnoType::get())); } } } diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx index 69b4f91b66af..066d8808262d 100644 --- a/package/source/xstor/owriteablestream.hxx +++ b/package/source/xstor/owriteablestream.hxx @@ -43,10 +43,12 @@ #include #include #include +#include #include #include +#include #include "ocompinstream.hxx" #include "mutexholder.hxx" @@ -65,10 +67,6 @@ struct PreCreationStruct }; -namespace cppu { - class OTypeCollection; -} - namespace package { bool PackageEncryptionDatasEqual( const ::comphelper::SequenceAsHashMap& aHash1, const ::comphelper::SequenceAsHashMap& aHash2 ); } @@ -76,14 +74,14 @@ namespace package { struct WSInternalData_Impl { SotMutexHolderRef m_rSharedMutexRef; - ::cppu::OTypeCollection* m_pTypeCollection; + ::std::unique_ptr< ::cppu::OTypeCollection> m_pTypeCollection; ::cppu::OMultiTypeInterfaceContainerHelper m_aListenersContainer; // list of listeners sal_Int32 m_nStorageType; // the mutex reference MUST NOT be empty WSInternalData_Impl( const SotMutexHolderRef& rMutexRef, sal_Int32 nStorageType ) : m_rSharedMutexRef( rMutexRef ) - , m_pTypeCollection( NULL ) + , m_pTypeCollection() , m_aListenersContainer( rMutexRef->GetMutex() ) , m_nStorageType( nStorageType ) {} -- cgit