summaryrefslogtreecommitdiff
path: root/sot/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-04-30 20:07:06 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-05-01 09:17:14 +0200
commitfe72e20f865baca9387e5d14327c56b2773d760f (patch)
treec5da9ce28a3432199154d040289bad95d5d1bfb1 /sot/source
parent4742808bf277cd33ef95029b987aac904149afd9 (diff)
CopyTo is never passed a null argument
Change-Id: Ie25e61d6795819a9c432d71fdf478b1a4430c06f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166940 Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sot/source')
-rw-r--r--sot/source/sdstor/stg.cxx16
-rw-r--r--sot/source/sdstor/storage.cxx2
-rw-r--r--sot/source/sdstor/ucbstorage.cxx24
-rw-r--r--sot/source/unoolestorage/xolesimplestorage.cxx2
4 files changed, 22 insertions, 22 deletions
diff --git a/sot/source/sdstor/stg.cxx b/sot/source/sdstor/stg.cxx
index 682aa08f504f..2b3e9a146908 100644
--- a/sot/source/sdstor/stg.cxx
+++ b/sot/source/sdstor/stg.cxx
@@ -684,7 +684,7 @@ bool Storage::CopyTo( const OUString& rElem, BaseStorage* pDest, const OUString&
if( !nTmpErr )
{
p2->SetClassId( p1->GetClassId() );
- p1->CopyTo( p2.get() );
+ p1->CopyTo( *p2 );
SetError( p1->GetError() );
nTmpErr = p2->GetError();
@@ -730,27 +730,27 @@ bool Storage::CopyTo( const OUString& rElem, BaseStorage* pDest, const OUString&
return false;
}
-bool Storage::CopyTo( BaseStorage* pDest ) const
+bool Storage::CopyTo( BaseStorage& rDest ) const
{
- if( !Validate() || !pDest || !pDest->Validate( true ) || Equals( *pDest ) )
+ if( !Validate() || !rDest.Validate( true ) || Equals( rDest ) )
{
SetError( SVSTREAM_ACCESS_DENIED );
return false;
}
Storage* pThis = const_cast<Storage*>(this);
- pDest->SetClassId( GetClassId() );
- pDest->SetDirty();
+ rDest.SetClassId( GetClassId() );
+ rDest.SetDirty();
SvStorageInfoList aList;
FillInfoList( &aList );
bool bRes = true;
for( size_t i = 0; i < aList.size() && bRes; i++ )
{
SvStorageInfo& rInfo = aList[ i ];
- bRes = pThis->CopyTo( rInfo.GetName(), pDest, rInfo.GetName() );
+ bRes = pThis->CopyTo( rInfo.GetName(), &rDest, rInfo.GetName() );
}
if( !bRes )
- SetError( pDest->GetError() );
- return Good() && pDest->Good();
+ SetError( rDest.GetError() );
+ return Good() && rDest.Good();
}
bool Storage::IsStorage( const OUString& rName ) const
diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx
index 937681ee56ef..a91c6f516a0b 100644
--- a/sot/source/sdstor/storage.cxx
+++ b/sot/source/sdstor/storage.cxx
@@ -461,7 +461,7 @@ bool SotStorage::CopyTo( SotStorage * pDestStg )
{
if( m_pOwnStg && pDestStg->m_pOwnStg )
{
- m_pOwnStg->CopyTo( pDestStg->m_pOwnStg );
+ m_pOwnStg->CopyTo( *pDestStg->m_pOwnStg );
SetError( m_pOwnStg->GetError() );
pDestStg->m_aKey = m_aKey;
pDestStg->m_nVersion = m_nVersion;
diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx
index a6f83bb33d77..41e134a345a6 100644
--- a/sot/source/sdstor/ucbstorage.cxx
+++ b/sot/source/sdstor/ucbstorage.cxx
@@ -2398,7 +2398,7 @@ bool UCBStorage::CopyStorageElement_Impl( UCBStorageElement_Impl const & rElemen
pUCBCopy->pImp->m_aUserTypeName );
else
pOtherStorage->SetClassId( pStorage->GetClassId() );
- pStorage->CopyTo( pOtherStorage.get() );
+ pStorage->CopyTo( *pOtherStorage );
SetError( pStorage->GetError() );
if( pOtherStorage->GetError() )
pDest->SetError( pOtherStorage->GetError() );
@@ -2423,10 +2423,10 @@ UCBStorageElement_Impl* UCBStorage::FindElement_Impl( std::u16string_view rName
return nullptr;
}
-bool UCBStorage::CopyTo( BaseStorage* pDestStg ) const
+bool UCBStorage::CopyTo( BaseStorage& rDestStg ) const
{
- DBG_ASSERT( pDestStg != static_cast<BaseStorage const *>(this), "Self-Copying is not possible!" );
- if ( pDestStg == static_cast<BaseStorage const *>(this) )
+ DBG_ASSERT( &rDestStg != static_cast<BaseStorage const *>(this), "Self-Copying is not possible!" );
+ if ( &rDestStg == static_cast<BaseStorage const *>(this) )
return false;
// perhaps it's also a problem if one storage is a parent of the other ?!
@@ -2434,24 +2434,24 @@ bool UCBStorage::CopyTo( BaseStorage* pDestStg ) const
// For UCB storages, the class id and the format id may differ,
// do passing the class id is not sufficient.
- if( dynamic_cast<const UCBStorage *>(pDestStg) != nullptr )
- pDestStg->SetClass( pImp->m_aClassId, pImp->m_nFormat,
- pImp->m_aUserTypeName );
+ if( dynamic_cast<const UCBStorage *>(&rDestStg) != nullptr )
+ rDestStg.SetClass( pImp->m_aClassId, pImp->m_nFormat,
+ pImp->m_aUserTypeName );
else
- pDestStg->SetClassId( GetClassId() );
- pDestStg->SetDirty();
+ rDestStg.SetClassId( GetClassId() );
+ rDestStg.SetDirty();
bool bRet = true;
for ( size_t i = 0; i < pImp->GetChildrenList().size() && bRet; ++i )
{
auto& pElement = pImp->GetChildrenList()[ i ];
if ( !pElement->m_bIsRemoved )
- bRet = CopyStorageElement_Impl( *pElement, pDestStg, pElement->m_aName );
+ bRet = CopyStorageElement_Impl( *pElement, &rDestStg, pElement->m_aName );
}
if( !bRet )
- SetError( pDestStg->GetError() );
- return Good() && pDestStg->Good();
+ SetError( rDestStg.GetError() );
+ return Good() && rDestStg.Good();
}
bool UCBStorage::CopyTo( const OUString& rElemName, BaseStorage* pDest, const OUString& rNew )
diff --git a/sot/source/unoolestorage/xolesimplestorage.cxx b/sot/source/unoolestorage/xolesimplestorage.cxx
index 46b82b2b538e..407c8d508233 100644
--- a/sot/source/unoolestorage/xolesimplestorage.cxx
+++ b/sot/source/unoolestorage/xolesimplestorage.cxx
@@ -387,7 +387,7 @@ uno::Any SAL_CALL OLESimpleStorage::getByName( const OUString& aName )
throw uno::RuntimeException();
std::unique_ptr<BaseStorage> pNewStor(new Storage( *pStream, false ));
- bool bSuccess = ( pStrg->CopyTo( pNewStor.get() ) && pNewStor->Commit() &&
+ bool bSuccess = ( pStrg->CopyTo( *pNewStor ) && pNewStor->Commit() &&
!pNewStor->GetError() && !pStrg->GetError() );
pNewStor.reset();