diff options
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/comp/dim.cxx | 4 | ||||
-rw-r--r-- | basic/source/comp/symtbl.cxx | 12 | ||||
-rw-r--r-- | basic/source/inc/symtbl.hxx | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index 3a984ce8c824..dc6bf5260448 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -1032,7 +1032,7 @@ void SbiParser::DefDeclare( bool bPrivate ) } else { - pDef->Match( std::unique_ptr<SbiProcDef>(p) ); + pDef->Match( p ); } } else @@ -1214,7 +1214,7 @@ void SbiParser::DefProc( bool bStatic, bool bPrivate ) } } - pDef->Match( std::unique_ptr<SbiProcDef>(pProc) ); + pDef->Match( pProc ); } else { diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx index 2002f3fce278..351cdaa818e5 100644 --- a/basic/source/comp/symtbl.cxx +++ b/basic/source/comp/symtbl.cxx @@ -409,7 +409,7 @@ void SbiProcDef::SetType( SbxDataType t ) // if the match is OK, pOld is replaced by this in the pool // pOld is deleted in any case! -void SbiProcDef::Match( std::unique_ptr<SbiProcDef> pOld ) +void SbiProcDef::Match( SbiProcDef* pOld ) { SbiSymDef *pn=nullptr; // parameter 0 is the function name @@ -433,16 +433,20 @@ void SbiProcDef::Match( std::unique_ptr<SbiProcDef> pOld ) pOld->pIn->GetParser()->SetCol1( 0 ); pOld->pIn->GetParser()->Error( ERRCODE_BASIC_BAD_DECLARATION, aName ); } + if( !pIn && pOld->pIn ) { // Replace old entry with the new one nPos = pOld->nPos; nId = pOld->nId; pIn = pOld->pIn; - std::unique_ptr<SbiSymDef> tmp(this); - std::swap(pIn->m_Data[nPos], tmp); - (void)tmp.release(); + + // don't delete pOld twice, if it's stored in m_Data + if (pOld == pIn->m_Data[nPos].get()) + pOld = nullptr; + pIn->m_Data[nPos].reset(this); } + delete pOld; } void SbiProcDef::setPropertyMode( PropertyMode ePropMode ) diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx index 3c0f9bf0128e..64a11ea814f3 100644 --- a/basic/source/inc/symtbl.hxx +++ b/basic/source/inc/symtbl.hxx @@ -194,7 +194,7 @@ public: // Match with a forward-declaration. The parameter names are // compared and the forward declaration is replaced by this - void Match( std::unique_ptr<SbiProcDef> pForward ); + void Match( SbiProcDef* pForward ); private: SbiProcDef( const SbiProcDef& ) = delete; |