summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-03-12 18:16:57 +0100
committerMichael Stahl <mstahl@redhat.com>2015-03-12 20:22:11 +0100
commit2877e5a9c7507acc9282e70323259b5c043dda0c (patch)
treea2290b768df9b7c70ce59878037903c6883567c8 /package
parentcd347b3b34343d696a3c90352ff91eb64a1057b0 (diff)
package: PVS-Studio V595 'm_pData' pointer could be null
... just convert its explicitly deleted member to unique_ptr. Change-Id: I826257ff512632a2aedd53a7ce5e4bedf49c3cfe
Diffstat (limited to 'package')
-rw-r--r--package/source/xstor/owriteablestream.cxx31
-rw-r--r--package/source/xstor/owriteablestream.hxx10
2 files changed, 18 insertions, 23 deletions
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<embed::XTransactedObject>::get()
, cppu::UnoType<embed::XTransactionBroadcaster>::get());
- m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+ m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection
( cppu::UnoType<beans::XPropertySet>::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<lang::XTypeProvider>::get()
, cppu::UnoType<io::XInputStream>::get()
, cppu::UnoType<io::XOutputStream>::get()
@@ -1964,11 +1961,11 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, cppu::UnoType<embed::XExtendedStorageStream>::get()
, cppu::UnoType<embed::XTransactedObject>::get()
, cppu::UnoType<embed::XTransactionBroadcaster>::get()
- , cppu::UnoType<beans::XPropertySet>::get());
+ , cppu::UnoType<beans::XPropertySet>::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<lang::XTypeProvider>::get()
, cppu::UnoType<io::XInputStream>::get()
, cppu::UnoType<io::XOutputStream>::get()
@@ -1979,14 +1976,14 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, cppu::UnoType<embed::XExtendedStorageStream>::get()
, cppu::UnoType<embed::XTransactedObject>::get()
, cppu::UnoType<embed::XTransactionBroadcaster>::get()
- , cppu::UnoType<beans::XPropertySet>::get());
+ , cppu::UnoType<beans::XPropertySet>::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<lang::XTypeProvider>::get()
, cppu::UnoType<io::XInputStream>::get()
, cppu::UnoType<io::XOutputStream>::get()
@@ -1996,11 +1993,11 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, cppu::UnoType<lang::XComponent>::get()
, cppu::UnoType<embed::XEncryptionProtectedSource2>::get()
, cppu::UnoType<embed::XEncryptionProtectedSource>::get()
- , cppu::UnoType<beans::XPropertySet>::get());
+ , cppu::UnoType<beans::XPropertySet>::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<lang::XTypeProvider>::get()
, cppu::UnoType<io::XInputStream>::get()
, cppu::UnoType<io::XOutputStream>::get()
@@ -2009,11 +2006,11 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, cppu::UnoType<io::XTruncate>::get()
, cppu::UnoType<lang::XComponent>::get()
, cppu::UnoType<embed::XRelationshipAccess>::get()
- , cppu::UnoType<beans::XPropertySet>::get());
+ , cppu::UnoType<beans::XPropertySet>::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<lang::XTypeProvider>::get()
, cppu::UnoType<io::XInputStream>::get()
, cppu::UnoType<io::XOutputStream>::get()
@@ -2021,7 +2018,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, cppu::UnoType<io::XSeekable>::get()
, cppu::UnoType<io::XTruncate>::get()
, cppu::UnoType<lang::XComponent>::get()
- , cppu::UnoType<beans::XPropertySet>::get());
+ , cppu::UnoType<beans::XPropertySet>::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 <cppuhelper/implbase1.hxx>
#include <cppuhelper/weak.hxx>
#include <cppuhelper/interfacecontainer.h>
+#include <cppuhelper/typeprovider.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <list>
+#include <memory>
#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 )
{}