summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-03-23 14:26:55 +0100
committerAndras Timar <andras.timar@collabora.com>2016-04-10 21:24:04 +0200
commit168f8730e670a4ab6adef4fe7b48ed080af8b914 (patch)
treeffe1f5cdb6748bfabab83a0729745baa124f2b0e
parent1f2d5d96389f550a87e2c954da0bad9496ab78e9 (diff)
add a recursion guard to lcl_FindRangeNamesInUse()
Change-Id: Ifbc02304f5a2e080db2d6645e2c7f825a2c56cb5 Reviewed-on: https://gerrit.libreoffice.org/23473 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit fecbcf523ee1e8a13b18ba1cfde36a2368da6949)
-rw-r--r--sc/source/core/data/formulacell.cxx14
1 files changed, 9 insertions, 5 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index f9c92e6f4fc7..ceb7f68d6a6f 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3555,7 +3555,8 @@ void ScFormulaCell::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY
StartListeningTo( pDocument ); // Listener as previous
}
-static void lcl_FindRangeNamesInUse(std::set<sal_uInt16>& rIndexes, ScTokenArray* pCode, ScRangeName* pNames)
+static void lcl_FindRangeNamesInUse(std::set<sal_uInt16>& rIndexes, ScTokenArray* pCode, ScRangeName* pNames,
+ int nRecursion)
{
for (FormulaToken* p = pCode->First(); p; p = pCode->Next())
{
@@ -3564,16 +3565,19 @@ static void lcl_FindRangeNamesInUse(std::set<sal_uInt16>& rIndexes, ScTokenArray
sal_uInt16 nTokenIndex = p->GetIndex();
rIndexes.insert( nTokenIndex );
- ScRangeData* pSubName = pNames->findByIndex(p->GetIndex());
- if (pSubName)
- lcl_FindRangeNamesInUse(rIndexes, pSubName->GetCode(), pNames);
+ if (nRecursion < 126) // whatever.. 42*3
+ {
+ ScRangeData* pSubName = pNames->findByIndex(p->GetIndex());
+ if (pSubName)
+ lcl_FindRangeNamesInUse(rIndexes, pSubName->GetCode(), pNames, nRecursion+1);
+ }
}
}
}
void ScFormulaCell::FindRangeNamesInUse(std::set<sal_uInt16>& rIndexes) const
{
- lcl_FindRangeNamesInUse( rIndexes, pCode, pDocument->GetRangeName() );
+ lcl_FindRangeNamesInUse( rIndexes, pCode, pDocument->GetRangeName(), 0);
}
void ScFormulaCell::SetChanged(bool b)