sc/source/core/tool/interpr4.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
New commits: commit a97afa2da0a299c1eb6fa6dad2b7add0e6e6feca Author: Eike Rathke <er...@redhat.com> AuthorDate: Mon Feb 27 23:14:01 2023 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue Feb 28 22:38:59 2023 +0000 Underflow assert also in already calculated path Change-Id: I7bd1c4960280a6526bb82e5b95c5253775df1e1a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147937 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147958 Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> 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); }