sc/source/filter/html/htmlpars.cxx |   25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

New commits:
commit 26706d907e043f10d92aa81433d712f07c6ee16b
Author:     Caolán McNamara <[email protected]>
AuthorDate: Sat Mar 23 15:40:26 2024 +0000
Commit:     Xisco Fauli <[email protected]>
CommitDate: Mon Mar 25 09:59:13 2024 +0100

    ofz#67540 negative offset
    
    Change-Id: I498985962feb7d77c1a71af7002a85aa02aa3e65
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165188
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index 8b50901f7050..70a2a10302fd 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -828,19 +828,22 @@ void ScHTMLLayoutParser::SetWidths()
             for ( size_t i = nFirstTableCell, nListSize = maList.size(); i < 
nListSize; ++i )
             {
                 auto& pE = maList[ i ];
-                if ( pE->nTab == nTable )
+                if (pE->nTab != nTable)
+                    continue;
+                nCol = pE->nCol - nColCntStart;
+                OSL_ENSURE( nCol < nColsPerRow, 
"ScHTMLLayoutParser::SetWidths: column overflow" );
+                if (nCol >= nColsPerRow)
+                    continue;
+                pE->nOffset = pOffsets[nCol];
+                nCol = nCol + pE->nColOverlap;
+                if ( nCol > nColsPerRow )
+                    nCol = nColsPerRow;
+                if (nCol < 0)
                 {
-                    nCol = pE->nCol - nColCntStart;
-                    OSL_ENSURE( nCol < nColsPerRow, 
"ScHTMLLayoutParser::SetWidths: column overflow" );
-                    if ( nCol < nColsPerRow )
-                    {
-                        pE->nOffset = pOffsets[nCol];
-                        nCol = nCol + pE->nColOverlap;
-                        if ( nCol > nColsPerRow )
-                            nCol = nColsPerRow;
-                        pE->nWidth = pOffsets[nCol] - pE->nOffset;
-                    }
+                    SAL_WARN("sc", "negative offset: " << nCol);
+                    continue;
                 }
+                pE->nWidth = pOffsets[nCol] - pE->nOffset;
             }
         }
     }

Reply via email to