sc/source/core/tool/interpr1.cxx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
New commits: commit 3c53ab89693bd0e930c0a9b8a222199c5b714171 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Feb 5 11:49:04 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Feb 15 13:41:54 2025 +0100 ScIndex doesn't need GetUInt32 The minimal allowed value for the fourth argument is 1. Using GetInt32 allows to easily switch to GetInt32WithDefault, if needed. Change-Id: I5b7585b939ae71b417597c5f389197b3df6c0d29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181696 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index e651348598d4..aebde2e3087a 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -10877,12 +10877,12 @@ void ScInterpreter::ScIndex() if ( !MustHaveParamCount( nParamCount, 1, 4 ) ) return; - sal_uInt32 nArea; + sal_Int32 nArea; size_t nAreaCount; SCCOL nCol; SCROW nRow; if (nParamCount == 4) - nArea = GetUInt32(); + nArea = GetInt32(); else nArea = 1; bool bColMissing; @@ -10900,28 +10900,27 @@ void ScInterpreter::ScIndex() nRow = static_cast<SCROW>(GetInt32()); else nRow = 0; + if (nArea < 1 || nCol < 0 || nRow < 0) + { + PushIllegalArgument(); + return; + } if (GetStackType() == svRefList) nAreaCount = (sp ? pStack[sp-1]->GetRefList()->size() : 0); else nAreaCount = 1; // one reference or array or whatever - if (nGlobalError != FormulaError::NONE || nAreaCount == 0 || static_cast<size_t>(nArea) > nAreaCount) + if (nGlobalError != FormulaError::NONE || nAreaCount == 0 || o3tl::make_unsigned(nArea) > nAreaCount) { PushError( FormulaError::NoRef); return; } - else if (nArea < 1 || nCol < 0 || nRow < 0) - { - PushIllegalArgument(); - return; - } switch (GetStackType()) { case svMatrix: case svExternalSingleRef: case svExternalDoubleRef: { - if (nArea != 1) - SetError(FormulaError::IllegalArgument); + assert(nArea == 1); sal_uInt16 nOldSp = sp; ScMatrixRef pMat = GetMatrix(); if (!pMat)