summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2023-02-27 23:14:01 +0100
committerAndras Timar <andras.timar@collabora.com>2023-04-04 13:54:11 +0200
commit381c706e5e010196c81109dafbc372c84aecb670 (patch)
treee11c8ada4e1848e5a416488fe9c1288108713349
parente84c6947a949d9bfd26d8032e2b8e7280fe3265c (diff)
Underflow assert also in already calculated path
Change-Id: I7bd1c4960280a6526bb82e5b95c5253775df1e1a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147937 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147958 Tested-by: Thorsten Behrens <thorsten.behrens@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r--sc/source/core/tool/interpr4.cxx17
1 files changed, 14 insertions, 3 deletions
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 002c7de4c1da..170e60f6afca 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3982,9 +3982,20 @@ StackVar ScInterpreter::Interpret()
(*aTokenMatrixMapIter).second->GetType() != svJumpMatrix)
{
// Path already calculated, reuse result.
- nStackBase = sp - pCur->GetParamCount();
- if ( nStackBase > sp )
- nStackBase = sp; // underflow?!?
+ if (sp >= pCur->GetParamCount())
+ nStackBase = sp - pCur->GetParamCount();
+ else
+ {
+ SAL_WARN("sc.core", "Stack anomaly with calculated path at "
+ << aPos.Tab() << "," << aPos.Col() << "," << aPos.Row()
+ << " " << aPos.Format(
+ ScRefFlags::VALID | ScRefFlags::FORCE_DOC | ScRefFlags::TAB_3D, pDok)
+ << " eOp: " << static_cast<int>(eOp)
+ << " params: " << static_cast<int>(pCur->GetParamCount())
+ << " nStackBase: " << nStackBase << " sp: " << sp);
+ nStackBase = sp;
+ assert(!"underflow");
+ }
sp = nStackBase;
PushTokenRef( (*aTokenMatrixMapIter).second);
}