[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Wed Mar 23 13:19:48 UTC 2016


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

New commits:
commit 8f61630300974b0a41e8b2ea6b9ec87f1c9faa5f
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Mar 23 14:17:19 2016 +0100

    add a recursion guard to lcl_FindRangeNamesInUse()
    
    Change-Id: Ia4a8f0273bb30b696b3499e75fa70e5c1a0981f1

diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 00badf0..94677ff 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3710,7 +3710,8 @@ void ScFormulaCell::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY
         StartListeningTo( pDocument ); // Listener as previous
 }
 
-static void lcl_FindRangeNamesInUse(sc::UpdatedRangeNames& rIndexes, ScTokenArray* pCode, const ScDocument* pDoc)
+static void lcl_FindRangeNamesInUse(sc::UpdatedRangeNames& rIndexes, ScTokenArray* pCode, const ScDocument* pDoc,
+        int nRecursion)
 {
     for (FormulaToken* p = pCode->First(); p; p = pCode->Next())
     {
@@ -3720,16 +3721,19 @@ static void lcl_FindRangeNamesInUse(sc::UpdatedRangeNames& rIndexes, ScTokenArra
             SCTAB nTab = p->GetSheet();
             rIndexes.setUpdatedName( nTab, nTokenIndex);
 
-            ScRangeData* pSubName = pDoc->FindRangeNameByIndexAndSheet( nTokenIndex, nTab);
-            if (pSubName)
-                lcl_FindRangeNamesInUse(rIndexes, pSubName->GetCode(), pDoc);
+            if (nRecursion < 126)   // whatever.. 42*3
+            {
+                ScRangeData* pSubName = pDoc->FindRangeNameByIndexAndSheet( nTokenIndex, nTab);
+                if (pSubName)
+                    lcl_FindRangeNamesInUse(rIndexes, pSubName->GetCode(), pDoc, nRecursion+1);
+            }
         }
     }
 }
 
 void ScFormulaCell::FindRangeNamesInUse(sc::UpdatedRangeNames& rIndexes) const
 {
-    lcl_FindRangeNamesInUse( rIndexes, pCode, pDocument );
+    lcl_FindRangeNamesInUse( rIndexes, pCode, pDocument, 0);
 }
 
 void ScFormulaCell::SetChanged(bool b)


More information about the Libreoffice-commits mailing list