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 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'package/source/xstor/owriteablestream.cxx') 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())); } } } -- cgit v1.2.3