summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-03-15 17:39:03 +0100
committerAndras Timar <andras.timar@collabora.com>2016-03-17 14:26:01 +0100
commit45316f69db01efd67a4c89dedb11b72d2b9efbb9 (patch)
treee55fd06323bbae95ed93fbc5ddd0732a51b6380b /sc
parent1cf84225cd93973fddafbd1d6887665765023a0a (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> (cherry picked from commit b14cc2f16d00c103cf415a54e163d54764d0a86b)
Diffstat (limited to 'sc')
-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)