diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-10 14:14:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-10 15:14:48 +0200 |
commit | 0afb2b63b38dff138e66f4ac8afed60911cb6aad (patch) | |
tree | 6f0d5e837600a460a57fce6383bc4eef10cdfc7a /basic/source/sbx | |
parent | b3541dea4889b9d0039554f87bd16e55189cf8b1 (diff) |
fix some leaks in basic
Change-Id: I52c10cdbe9661974c908ee052336c779a40de402
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115323
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic/source/sbx')
-rw-r--r-- | basic/source/sbx/sbxarray.cxx | 2 | ||||
-rw-r--r-- | basic/source/sbx/sbxbase.cxx | 16 | ||||
-rw-r--r-- | basic/source/sbx/sbxobj.cxx | 10 | ||||
-rw-r--r-- | basic/source/sbx/sbxvalue.cxx | 5 |
4 files changed, 18 insertions, 15 deletions
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx index 06774acddc00..a54845d1c7c8 100644 --- a/basic/source/sbx/sbxarray.cxx +++ b/basic/source/sbx/sbxarray.cxx @@ -338,7 +338,7 @@ bool SbxArray::LoadData( SvStream& rStrm, sal_uInt16 /*nVer*/ ) { sal_uInt16 nIdx; rStrm.ReadUInt16( nIdx ); - SbxVariable* pVar = static_cast<SbxVariable*>(Load( rStrm )); + SbxVariableRef pVar = static_cast<SbxVariable*>(Load( rStrm ).get()); if( pVar ) { SbxVariableRef& rRef = GetRef( nIdx ); diff --git a/basic/source/sbx/sbxbase.cxx b/basic/source/sbx/sbxbase.cxx index b980e0e9e2d7..3b70307ec3e7 100644 --- a/basic/source/sbx/sbxbase.cxx +++ b/basic/source/sbx/sbxbase.cxx @@ -129,7 +129,7 @@ void SbxBase::RemoveFactory( SbxFactory const * pFac ) } -SbxBase* SbxBase::Create( sal_uInt16 nSbxId, sal_uInt32 nCreator ) +SbxBaseRef SbxBase::Create( sal_uInt16 nSbxId, sal_uInt32 nCreator ) { // #91626: Hack to skip old Basic dialogs // Problem: There does not exist a factory any more, @@ -153,7 +153,7 @@ SbxBase* SbxBase::Create( sal_uInt16 nSbxId, sal_uInt32 nCreator ) } // Unknown type: go over the factories! SbxAppData& r = GetSbxData_Impl(); - SbxBase* pNew = nullptr; + SbxBaseRef pNew; for (auto const& rpFac : r.m_Factories) { pNew = rpFac->Create( nSbxId, nCreator ); @@ -164,10 +164,10 @@ SbxBase* SbxBase::Create( sal_uInt16 nSbxId, sal_uInt32 nCreator ) return pNew; } -SbxObject* SbxBase::CreateObject( const OUString& rClass ) +SbxObjectRef SbxBase::CreateObject( const OUString& rClass ) { SbxAppData& r = GetSbxData_Impl(); - SbxObject* pNew = nullptr; + SbxObjectRef pNew; for (auto const& rpFac : r.m_Factories) { pNew = rpFac->CreateObject( rClass ); @@ -191,7 +191,7 @@ namespace { } -SbxBase* SbxBase::Load( SvStream& rStrm ) +SbxBaseRef SbxBase::Load( SvStream& rStrm ) { sal_uInt16 nSbxId(0), nFlagsTmp(0), nVer(0); sal_uInt32 nCreator(0), nSize(0); @@ -200,7 +200,7 @@ SbxBase* SbxBase::Load( SvStream& rStrm ) sal_uInt64 nOldPos = rStrm.Tell(); rStrm.ReadUInt32( nSize ); - SbxBase* p = Create( nSbxId, nCreator ); + SbxBaseRef p = Create( nSbxId, nCreator ); if( p ) { p->nFlags = nFlags; @@ -267,12 +267,12 @@ SbxFactory::~SbxFactory() { } -SbxBase* SbxFactory::Create( sal_uInt16, sal_uInt32 ) +SbxBaseRef SbxFactory::Create( sal_uInt16, sal_uInt32 ) { return nullptr; } -SbxObject* SbxFactory::CreateObject( const OUString& ) +SbxObjectRef SbxFactory::CreateObject( const OUString& ) { return nullptr; } diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx index 6beae9ac7ffe..7f3560a62003 100644 --- a/basic/source/sbx/sbxobj.cxx +++ b/basic/source/sbx/sbxobj.cxx @@ -364,7 +364,7 @@ SbxVariable* SbxObject::Make( const OUString& rName, SbxClassType ct, SbxDataTyp return pRes; } } - SbxVariable* pVar = nullptr; + SbxVariableRef pVar; switch( ct ) { case SbxClassType::Variable: @@ -375,17 +375,17 @@ SbxVariable* SbxObject::Make( const OUString& rName, SbxClassType ct, SbxDataTyp pVar = new SbxMethod( rName, dt, bIsRuntimeFunction ); break; case SbxClassType::Object: - pVar = CreateObject( rName ); + pVar = CreateObject( rName ).get(); break; default: break; } pVar->SetParent( this ); - pArray->Put(pVar, pArray->Count()); + pArray->Put(pVar.get(), pArray->Count()); SetModified( true ); // The object listen always StartListening(pVar->GetBroadcaster(), DuplicateHandling::Prevent); - return pVar; + return pVar.get(); } void SbxObject::Insert( SbxVariable* pVar ) @@ -532,7 +532,7 @@ void SbxObject::Remove( SbxVariable* pVar ) static bool LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray ) { - SbxArrayRef p = static_cast<SbxArray*>( SbxBase::Load( rStrm ) ); + SbxArrayRef p = static_cast<SbxArray*>( SbxBase::Load( rStrm ).get() ); if( !p.is() ) { return false; diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index 403a7f842554..e67044def3f3 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -1383,11 +1383,14 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) aData.pObj = nullptr; break; case 1: - aData.pObj = SbxBase::Load( r ); + { + auto ref = SbxBase::Load( r ); + aData.pObj = ref.get(); // if necessary increment Ref-Count if (aData.pObj) aData.pObj->AddFirstRef(); return ( aData.pObj != nullptr ); + } case 2: aData.pObj = this; break; |