summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-03-15 17:39:03 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-03-15 21:09:29 +0000
commitb14cc2f16d00c103cf415a54e163d54764d0a86b (patch)
treeb693e2afa13a649ba5108b9ebb2f2838ec1c4d70
parent96a3261aae5c38cbb303a7c63a7631f13be898a3 (diff)
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/23280 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/source/core/data/formulacell.cxx48
1 files changed, 29 insertions, 19 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 36c64e19c743..b34261bf6c0a 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1438,6 +1438,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 (!IsDirtyOrInTableOpDirty() || pDocument->GetRecursionHelper().IsInReturn())
@@ -1680,25 +1702,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() )
{
@@ -3844,6 +3848,12 @@ bool ScFormulaCell::InterpretFormulaGroup()
if (!officecfg::Office::Common::Misc::UseOpenCL::get())
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)