sc/source/ui/view/viewfunc.cxx | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
New commits: commit 661d22e86175fe919e956c9c6a1278d73758d54c Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Tue Mar 12 12:20:56 2019 +0100 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Mar 12 18:55:49 2019 +0100 fix a possible ScTokenArray leak To me it looks like pArr is leaked in the bAgain = true case, or the code is rather misleading. Change-Id: I41ea26052671f127141d5421d0c446da4606da28 Reviewed-on: https://gerrit.libreoffice.org/69091 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 12b78243c34d..00c0678ba32c 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -409,17 +409,19 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, aComp.SetExtendedErrorDetection( ScCompiler::EXTENDED_ERROR_DETECTION_NAME_BREAK ); } OUString aFormula( rString ); - ScTokenArray* pArr; + std::unique_ptr< ScTokenArray > pArr; bool bAgain; do { bAgain = false; bool bAddEqual = false; - ScTokenArray* pArrFirst = pArr = aComp.CompileString( aFormula ).release(); + pArr = aComp.CompileString( aFormula ); bool bCorrected = aComp.IsCorrected(); + std::unique_ptr< ScTokenArray > pArrFirst; if ( bCorrected ) { // try to parse with first parser-correction - pArr = aComp.CompileString( aComp.GetCorrectedFormula() ).release(); + pArrFirst = std::move( pArr ); + pArr = aComp.CompileString( aComp.GetCorrectedFormula() ); } if ( pArr->GetCodeError() == FormulaError::NONE ) { @@ -454,17 +456,12 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, if ( nResult == RET_YES ) { aFormula = aCorrectedFormula; - if ( pArr != pArrFirst ) - delete pArrFirst; bAgain = true; } else { - if ( pArr != pArrFirst ) - { - delete pArr; - pArr = pArrFirst; - } + if ( pArrFirst ) + pArr = std::move( pArrFirst ); } } } while ( bAgain ); @@ -507,8 +504,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, } } - ScFormulaCell aCell(pDoc, aPos, *pArr, formula::FormulaGrammar::GRAM_DEFAULT, ScMatrixMode::NONE); - delete pArr; + ScFormulaCell aCell(pDoc, aPos, std::move( pArr ), formula::FormulaGrammar::GRAM_DEFAULT, ScMatrixMode::NONE); SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); for (const auto& rTab : rMark) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits