sc/source/core/tool/interpr1.cxx | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
New commits: commit 35e3c499cb64ed647fc8cc0a42a2d83948abcbdf Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sun Feb 19 17:33:20 2023 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sun Feb 19 19:19:50 2023 +0000 crashtesting: crash on import of forum-mso-en4-702161.xlsx vConditions is empty at this point for row 5 git show -w Change-Id: I05d984d73d4dd5a0ece894f854263528c9c00be9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147303 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 28523ff77a4a..18680eb5ddce 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -6497,25 +6497,29 @@ void ScInterpreter::IterateParametersIfs( double(*ResultFunc)( const sc::ParamIf if (nRefArrayMainPos < vRefArrayConditions.size()) vConditions = vRefArrayConditions[nRefArrayMainPos]; - std::vector<sal_uInt8>::const_iterator itRes = vConditions.begin(); - for (SCCOL nCol = 0; nCol < nDimensionCols; ++nCol) + SAL_WARN_IF(nDimensionCols && nDimensionRows && vConditions.empty(), "sc", "ScInterpreter::IterateParametersIfs vConditions is empty"); + if (!vConditions.empty()) { - for (SCROW nRow = 0; nRow < nDimensionRows; ++nRow, ++itRes) + std::vector<sal_uInt8>::const_iterator itRes = vConditions.begin(); + for (SCCOL nCol = 0; nCol < nDimensionCols; ++nCol) { - if (*itRes == nQueryCount) + for (SCROW nRow = 0; nRow < nDimensionRows; ++nRow, ++itRes) { - aAdr.SetCol( nCol + nMainCol1); - aAdr.SetRow( nRow + nMainRow1); - ScRefCellValue aCell(mrDoc, aAdr); - if (aCell.hasNumeric()) + if (*itRes == nQueryCount) { - fVal = GetCellValue(aAdr, aCell); - ++aRes.mfCount; - aRes.mfSum += fVal; - if ( aRes.mfMin > fVal ) - aRes.mfMin = fVal; - if ( aRes.mfMax < fVal ) - aRes.mfMax = fVal; + aAdr.SetCol( nCol + nMainCol1); + aAdr.SetRow( nRow + nMainRow1); + ScRefCellValue aCell(mrDoc, aAdr); + if (aCell.hasNumeric()) + { + fVal = GetCellValue(aAdr, aCell); + ++aRes.mfCount; + aRes.mfSum += fVal; + if ( aRes.mfMin > fVal ) + aRes.mfMin = fVal; + if ( aRes.mfMax < fVal ) + aRes.mfMax = fVal; + } } } }