sc/source/core/tool/interpr1.cxx |   34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

New commits:
commit 0f305c976c4a619f53154d13be134d3bbe6f3302
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Feb 19 17:33:20 2023 +0000
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Thu Feb 23 19:29:11 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>
    (cherry picked from commit 35e3c499cb64ed647fc8cc0a42a2d83948abcbdf)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147287
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 405d9fe00023..5673bb7ecda2 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6491,25 +6491,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;
+                                    }
                                 }
                             }
                         }

Reply via email to