sc/source/core/data/formulacell.cxx |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit c2728179ddd42793319988cc3e6014ee1971c1cf
Author: Eike Rathke <er...@redhat.com>
Date:   Wed Mar 23 14:26:55 2016 +0100

    add a recursion guard to lcl_FindRangeNamesInUse()
    
    Change-Id: Ifbc02304f5a2e080db2d6645e2c7f825a2c56cb5
    Reviewed-on: https://gerrit.libreoffice.org/23472
    Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrh...@googlemail.com>

diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 8ab094c..d9f48e1 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3678,7 +3678,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())
     {
@@ -3687,16 +3688,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)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to