sc/source/filter/html/htmlpars.cxx | 38 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-)
New commits: commit b866019e6ee82ce19dacd653861f8d2b701d2a8e Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sat Mar 23 21:31:51 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sun Mar 24 20:49:54 2024 +0100 ofz#67563 infinite loop Change-Id: I1654d23fd8768a77d32fc3150a9d8554afa2e91f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165220 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 7e83ce098979..e5b25bb42bd1 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -721,7 +721,6 @@ sal_uInt16 ScHTMLLayoutParser::GetWidth( const ScEEParseEntry* pE ) void ScHTMLLayoutParser::SetWidths() { - SCCOL nCol; if ( !nTableWidth ) nTableWidth = static_cast<sal_uInt16>(aPageSize.Width()); SCCOL nColsPerRow = nMaxCol - nColCntStart; @@ -732,7 +731,7 @@ void ScHTMLLayoutParser::SetWidths() sal_uInt16 nWidth = nTableWidth / static_cast<sal_uInt16>(nColsPerRow); sal_uInt16 nOff = nColOffsetStart; xLocalColOffset->clear(); - for ( nCol = 0; nCol <= nColsPerRow; ++nCol, nOff = nOff + nWidth ) + for (int nCol = 0; nCol <= nColsPerRow; ++nCol, nOff = nOff + nWidth) { MakeColNoRef( xLocalColOffset.get(), nOff, 0, 0, 0 ); } @@ -767,7 +766,7 @@ void ScHTMLLayoutParser::SetWidths() auto& pE = maList[ i ]; if ( pE->nTab == nTable && pE->nWidth ) { - nCol = pE->nCol - nColCntStart; + SCCOL nCol = pE->nCol - nColCntStart; if ( nCol < nColsPerRow ) { if ( pE->nColOverlap == 1 ) @@ -804,7 +803,7 @@ void ScHTMLLayoutParser::SetWidths() } sal_uInt16 nWidths = 0; sal_uInt16 nUnknown = 0; - for ( nCol = 0; nCol < nColsPerRow; nCol++ ) + for (SCCOL nCol = 0; nCol < nColsPerRow; nCol++) { if ( pWidths[nCol] ) nWidths = nWidths + pWidths[nCol]; @@ -816,18 +815,18 @@ void ScHTMLLayoutParser::SetWidths() sal_uInt16 nW = ((nWidths < nTableWidth) ? ((nTableWidth - nWidths) / nUnknown) : (nTableWidth / nUnknown)); - for ( nCol = 0; nCol < nColsPerRow; nCol++ ) + for (SCCOL nCol = 0; nCol < nColsPerRow; nCol++) { if ( !pWidths[nCol] ) pWidths[nCol] = nW; } } - for ( nCol = 1; nCol <= nColsPerRow; nCol++ ) + for (SCCOL nCol = 1; nCol <= nColsPerRow; nCol++) { pOffsets[nCol] = pOffsets[nCol-1] + pWidths[nCol-1]; } xLocalColOffset->clear(); - for ( nCol = 0; nCol <= nColsPerRow; nCol++ ) + for (SCCOL nCol = 0; nCol <= nColsPerRow; nCol++) { MakeColNoRef( xLocalColOffset.get(), pOffsets[nCol], 0, 0, 0 ); } @@ -838,7 +837,7 @@ void ScHTMLLayoutParser::SetWidths() auto& pE = maList[ i ]; if (pE->nTab != nTable) continue; - nCol = pE->nCol - nColCntStart; + SCCOL nCol = pE->nCol - nColCntStart; OSL_ENSURE( nCol < nColsPerRow, "ScHTMLLayoutParser::SetWidths: column overflow" ); if (nCol >= nColsPerRow) continue; commit 53680642cc5ea3df512b7e35a199b6ed6e9d9c39 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sat Mar 23 15:40:26 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sun Mar 24 20:49:44 2024 +0100 ofz#67540 negative offset Change-Id: I498985962feb7d77c1a71af7002a85aa02aa3e65 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165217 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 232a3d9c84fa..7e83ce098979 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -836,19 +836,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; } } }