sc/source/core/data/formulacell.cxx |   48 +++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 19 deletions(-)

New commits:
commit c56e92e4ed1f11de5c89b4a5eda6f91de3053941
Author: Eike Rathke <er...@redhat.com>
Date:   Tue Mar 15 17:39:03 2016 +0100

    Resolves: tdf#93196 add RecursionCounter guard also to 
InterpretFormulaGroup()
    
    ... same as for ScFormulaCell::InterpretTail()
    
    Change-Id: I444f259fe4e86ed0638a04f1b5d9272edd182e2e
    (cherry picked from commit 29ee431c1cf859c3d5a5041cff5cb04b89db27a0)
    Reviewed-on: https://gerrit.libreoffice.org/23279
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: David Tardon <dtar...@redhat.com>

diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 8b4a727..5fb2c7a 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1499,6 +1499,28 @@ bool ScFormulaCell::MarkUsedExternalReferences()
     return pCode && pDocument->MarkUsedExternalReferences(*pCode, aPos);
 }
 
+namespace {
+class RecursionCounter
+{
+    ScRecursionHelper&  rRec;
+    bool                bStackedInIteration;
+public:
+    RecursionCounter( ScRecursionHelper& r, ScFormulaCell* p ) : rRec(r)
+    {
+        bStackedInIteration = rRec.IsDoingIteration();
+        if (bStackedInIteration)
+            rRec.GetRecursionInIterationStack().push( p);
+        rRec.IncRecursionCount();
+    }
+    ~RecursionCounter()
+    {
+        rRec.DecRecursionCount();
+        if (bStackedInIteration)
+            rRec.GetRecursionInIterationStack().pop();
+    }
+};
+}
+
 void ScFormulaCell::Interpret()
 {
 #if DEBUG_CALCULATION
@@ -1769,25 +1791,7 @@ void ScFormulaCell::Interpret()
 
 void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
 {
-    class RecursionCounter
-    {
-        ScRecursionHelper&  rRec;
-        bool                bStackedInIteration;
-        public:
-        RecursionCounter( ScRecursionHelper& r, ScFormulaCell* p ) : rRec(r)
-        {
-            bStackedInIteration = rRec.IsDoingIteration();
-            if (bStackedInIteration)
-                rRec.GetRecursionInIterationStack().push( p);
-            rRec.IncRecursionCount();
-        }
-        ~RecursionCounter()
-        {
-            rRec.DecRecursionCount();
-            if (bStackedInIteration)
-                rRec.GetRecursionInIterationStack().pop();
-        }
-    } aRecursionCounter( pDocument->GetRecursionHelper(), this);
+    RecursionCounter aRecursionCounter( pDocument->GetRecursionHelper(), this);
     nSeenInIteration = pDocument->GetRecursionHelper().GetIteration();
     if( !pCode->GetCodeLen() && !pCode->GetCodeError() )
     {
@@ -3969,6 +3973,12 @@ bool ScFormulaCell::InterpretFormulaGroup()
     if (!ScCalcConfig::isOpenCLEnabled() && 
!ScCalcConfig::isSwInterpreterEnabled())
         return false;
 
+    // Guard against endless recursion of Interpret() calls, for this to work
+    // ScFormulaCell::InterpretFormulaGroup() must never be called through
+    // anything else than ScFormulaCell::Interpret(), same as
+    // ScFormulaCell::InterpretTail()
+    RecursionCounter aRecursionCounter( pDocument->GetRecursionHelper(), this);
+
     // TODO : Disable invariant formula group interpretation for now in order
     // to get implicit intersection to work.
     if (mxGroup->mbInvariant && false)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to