sw/source/core/docnode/nodes.cxx  |    1 +
 sw/source/core/fields/reffld.cxx  |    9 +++++----
 sw/source/core/layout/pagechg.cxx |    6 ++++--
 3 files changed, 10 insertions(+), 6 deletions(-)

New commits:
commit 31d0c99c31be9a83cb8dae9c7555f27083b3320c
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Dec 6 11:24:41 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Dec 6 12:14:11 2024 +0100

    add assert in SwNodes::ForEach
    
    to catch any dodgy code
    
    Change-Id: Iffd0612b28871c864f103634a40d13b82160d1ce
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177955
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index e11ee0ce49d8..c74731f48927 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -2275,6 +2275,7 @@ SwNode* SwNodes::FindPrvNxtFrameNode( const SwNode& 
rFrameNd,
 void SwNodes::ForEach( SwNodeOffset nStart, SwNodeOffset nEnd,
                        FnForEach_SwNodes fn, void* pArgs )
 {
+    assert( nEnd <= SwNodeOffset(m_nSize) );
     if( nEnd > SwNodeOffset(m_nSize) )
         nEnd = SwNodeOffset(m_nSize);
 
commit e7268b7d9e4ee79785116d1d80942cec8f035aae
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Dec 6 10:07:34 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Dec 6 12:14:02 2024 +0100

    tdf#119840 small tweaks
    
    Change-Id: Ie2c7a9633ee62bc1c4c0ad821d5ff1ace71fc15d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177928
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 99ef95713e1a..56b819c3d8dc 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -1217,16 +1217,17 @@ namespace
                                     sal_Int32 *const pStart, sal_Int32 *const 
pEnd,
                                     bool bCaseSensitive = true)
     {
-        if (*pCurrent == *pSelf)
+        if (pCurrent == pSelf)
             return nullptr;
 
         SwTextNode* pTextNode = pCurrent->GetTextNode();
         if (!pTextNode)
             return nullptr;
 
+        auto const & rFormatName = pTextNode->GetFormatColl()->GetName();
         if (bCaseSensitive
-            ? pTextNode->GetFormatColl()->GetName() == rStyleName
-            : 
pTextNode->GetFormatColl()->GetName().equalsIgnoreAsciiCase(rStyleName))
+            ? rFormatName == rStyleName
+            : rFormatName.equalsIgnoreAsciiCase(rStyleName))
         {
             *pStart = 0;
             if (pEnd)
@@ -1238,7 +1239,7 @@ namespace
 
         if (auto const pHints = pTextNode->GetpSwpHints())
         {
-            for (size_t i = 0; i < pHints->Count(); ++i)
+            for (size_t i = 0, nCnt = pHints->Count(); i < nCnt; ++i)
             {
                 auto const*const pHint(pHints->Get(i));
                 if (pHint->Which() == RES_TXTATR_CHARFMT)
diff --git a/sw/source/core/layout/pagechg.cxx 
b/sw/source/core/layout/pagechg.cxx
index 1c5d112dec72..ab18682e528d 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -410,12 +410,14 @@ static void lcl_FormatLay( SwLayoutFrame *pLay )
 static void lcl_MakeObjs(const sw::FrameFormats<sw::SpzFrameFormat*>& rSpzs, 
SwPageFrame* pPage)
 {
     // formats are in the special table of the document
+    const sal_uInt16 nPhyPageNum = pPage->GetPhyPageNum();
     size_t i = 0;
-    while (i < rSpzs.size())
+    const size_t nSpzsCnt = rSpzs.size();
+    while (i < nSpzsCnt)
     {
         auto pSpz = rSpzs[i];
         const SwFormatAnchor &rAnch = pSpz->GetAnchor();
-        if ( rAnch.GetPageNum() == pPage->GetPhyPageNum() )
+        if ( rAnch.GetPageNum() == nPhyPageNum )
         {
             if( rAnch.GetAnchorNode() )
             {

Reply via email to