sw/source/core/bastyp/index.cxx | 2 +- sw/source/filter/ww8/ww8par.cxx | 2 +- sw/source/filter/ww8/ww8par2.cxx | 6 +++--- sw/source/filter/ww8/ww8par5.cxx | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-)
New commits: commit 2476104c9168969b4970bd613a11078fec699435 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Aug 24 11:37:40 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Aug 24 12:51:08 2022 +0200 fix ubsan signed integer overflow after commit 6b544507b01d479b991d3ba7c949cb70696a3f2e Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Aug 23 11:42:38 2022 +0200 Use more SwPosition::Adjust ubsan started to complain because the SAL_WARN_IF here assumes that nVal is >= 0. Make it work if nVal is < 0. /sw/source/core/bastyp/index.cxx:332:5: runtime error: signed integer overflow: 2147483647 - -1 cannot be represented in type 'int' /sw/source/core/bastyp/index.cxx:332:5 /sw/source/core/crsr/pam.cxx:257:14 SwPaM*) /sw/source/uibase/wrtsh/wrtsh2.cxx:129:52 /sw/source/uibase/fldui/fldmgr.cxx:1490:39 SfxRequest const&) /sw/source/uibase/wrtsh/wrtsh1.cxx:2284:19 Change-Id: Ic9e98b5350a55713f6b3fc2b39c9cbce97ee7223 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138756 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx index f7868e8901e0..c7ded156ea26 100644 --- a/sw/source/core/bastyp/index.cxx +++ b/sw/source/core/bastyp/index.cxx @@ -329,7 +329,7 @@ sal_Int32 SwContentIndex::operator--() sal_Int32 SwContentIndex::operator+=( sal_Int32 const nVal ) { - SAL_WARN_IF( !(m_nIndex <= SAL_MAX_INT32 - nVal), "sw.core", + SAL_WARN_IF( !(nVal > 0 ? m_nIndex <= SAL_MAX_INT32 - nVal : m_nIndex >= nVal), "sw.core", "SwContentIndex SwContentIndex::operator+=(sal_Int32) wraps around" ); return ChgValue( *this, m_nIndex + nVal ).m_nIndex; } commit 47d51286103dc6fa2c4ddfa871bde4878aef17ef Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Aug 24 09:56:51 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Aug 24 12:50:57 2022 +0200 Use more SwPosition::Adjust to keep the internal fields of SwPosition in sync. Change-Id: Icdcf9db112f34b3164e52c33f90484755cc08ccf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138754 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 078d2aae5ddc..e18ab2e655c7 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -6720,7 +6720,7 @@ bool SwWW8ImplReader::InEqualApo(int nLvl) const namespace sw::hack { Position::Position(const SwPosition &rPos) - : maPtNode(rPos.nNode), mnPtContent(rPos.GetContentIndex()) + : maPtNode(rPos.GetNode()), mnPtContent(rPos.GetContentIndex()) { } diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 9b6cdfe6c754..08b7e8017a46 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -2366,7 +2366,7 @@ void wwSectionManager::PrependedInlineNode(const SwPosition &rPos, { OSL_ENSURE(!maSegments.empty(), "should not be possible, must be at least one segment"); - if ((!maSegments.empty()) && (maSegments.back().maStart == rPos.nNode)) + if ((!maSegments.empty()) && (maSegments.back().maStart == rPos.GetNode())) maSegments.back().maStart.Assign(rNode); } @@ -2649,13 +2649,13 @@ void WW8TabDesc::MergeCells() if( rCell.bVertMerge && !rCell.bVertRestart ) { SwPaM aPam( *m_pTabBox->GetSttNd(), 0 ); - aPam.GetPoint()->nNode++; + aPam.GetPoint()->Adjust(SwNodeOffset(1)); SwTextNode* pNd = aPam.GetPointNode().GetTextNode(); while( pNd ) { pNd->SetCountedInList( false ); - aPam.GetPoint()->nNode++; + aPam.GetPoint()->Adjust(SwNodeOffset(1)); pNd = aPam.GetPointNode().GetTextNode(); } } diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 12b940b96a9d..f137dfec72a4 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -529,7 +529,7 @@ sal_uInt16 SwWW8ImplReader::End_Field() case ww::eFORMTEXT: if (bUseEnhFields && m_pPaM!=nullptr && m_pPaM->GetPoint()!=nullptr) { SwPosition aEndPos = *m_pPaM->GetPoint(); - SwPaM aFieldPam( m_aFieldStack.back().GetPtNode(), m_aFieldStack.back().GetPtContent(), aEndPos.nNode, aEndPos.GetContentIndex()); + SwPaM aFieldPam( m_aFieldStack.back().GetPtNode().GetNode(), m_aFieldStack.back().GetPtContent(), aEndPos.GetNode(), aEndPos.GetContentIndex()); IDocumentMarkAccess* pMarksAccess = m_rDoc.getIDocumentMarkAccess( ); IFieldmark *pFieldmark = pMarksAccess->makeFieldBookmark( aFieldPam, m_aFieldStack.back().GetBookmarkName(), ODF_FORMTEXT, @@ -636,8 +636,8 @@ sal_uInt16 SwWW8ImplReader::End_Field() // Unhandled field with stored code SwPosition aEndPos = *m_pPaM->GetPoint(); SwPaM aFieldPam( - m_aFieldStack.back().GetPtNode(), m_aFieldStack.back().GetPtContent(), - aEndPos.nNode, aEndPos.GetContentIndex()); + m_aFieldStack.back().GetPtNode().GetNode(), m_aFieldStack.back().GetPtContent(), + aEndPos.GetNode(), aEndPos.GetContentIndex()); IDocumentMarkAccess* pMarksAccess = m_rDoc.getIDocumentMarkAccess( );