From 7c361df0481cb442a97d0d801e2b32652cc89eba Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 5 Oct 2026 15:40:54 +0200 Subject: [PATCH] docnode/section: Use SvRef::get() instead of &* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using &* can be problematic if the pointer is null. In this case it probably doesn’t matter, but using SvRef::get() is probably easier to understand anyway. This also paves the way for a later compiler plugin to check for this. Change-Id: I4de3949f3cac3a6cea448f878ca761a67750efc3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211846 Reviewed-by: Neil Roberts Tested-by: Jenkins --- sw/source/core/docnode/section.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index a394b8a3121c..d4df38af7e2b 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -1037,7 +1037,7 @@ static void lcl_BreakSectionLinksInSect( const SwSectionNode& rSectNd ) const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc().getIDocumentLinksAdministration().GetLinkManager().GetLinks(); for ( auto n = rLnks.size(); n > 0; ) { - SwIntrnlSectRefLink* pSectLnk = dynamic_cast(&(*rLnks[ --n ])); + SwIntrnlSectRefLink* pSectLnk = dynamic_cast(rLnks[ --n ].get()); if ( pSectLnk && pSectLnk != pOwnLink && pSectLnk->IsInRange( rSectNd.GetIndex(), rSectNd.EndOfSectionIndex() ) ) { @@ -1071,7 +1071,7 @@ static void lcl_UpdateLinksInSect( const SwBaseLink& rUpdLnk, SwSectionNode& rSe const ::sfx2::SvBaseLinks& rLnks = rDoc.getIDocumentLinksAdministration().GetLinkManager().GetLinks(); for( auto n = rLnks.size(); n; ) { - ::sfx2::SvBaseLink* pLnk = &(*rLnks[ --n ]); + ::sfx2::SvBaseLink* pLnk = rLnks[ --n ].get(); if( pLnk == &rUpdLnk ) continue; if( sfx2::SvBaseLinkObjectType::ClientFile != pLnk->GetObjType() ) @@ -1091,11 +1091,11 @@ static void lcl_UpdateLinksInSect( const SwBaseLink& rUpdLnk, SwSectionNode& rSe if( n >= rLnks.size() && 0 != ( n = rLnks.size() )) --n; - if( n && pLnk != &(*rLnks[ n ]) ) + if( n && pLnk != rLnks[ n ].get() ) { // Find - it can only precede it! while( n ) - if( pLnk == &(*rLnks[ --n ] ) ) + if( pLnk == rLnks[ --n ].get() ) break; } }