sw/source/core/layout/colfrm.cxx |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 32e792800a6635da9cdf88a2348e72c35286a2a2
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Dec 23 11:44:19 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Jan 7 12:28:16 2025 +0100

    crashreporting: check Lower()
    
    See 
https://crashreport.libreoffice.org/stats/signature/SwLayoutFrame::AdjustColumns(SwFormatCol%20const%20*,bool)
    
    Change-Id: I690a6358c8964f5511aedf3246384649cf004d9f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179234
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit e080eebd4ebb20ddb0aff1f168096ec22b326546)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179248
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/layout/colfrm.cxx b/sw/source/core/layout/colfrm.cxx
index 8b6aa8b60a3b..5aec69496c8c 100644
--- a/sw/source/core/layout/colfrm.cxx
+++ b/sw/source/core/layout/colfrm.cxx
@@ -312,9 +312,13 @@ void SwLayoutFrame::ChgColumns( const SwFormatCol &rOld, 
const SwFormatCol &rNew
 
 void SwLayoutFrame::AdjustColumns( const SwFormatCol *pAttr, bool 
bAdjustAttributes )
 {
-    if( !Lower()->GetNext() )
+    SwFrame* pLower = Lower();
+    if (!pLower)
+        return;
+
+    if( !pLower->GetNext() )
     {
-        Lower()->ChgSize( getFramePrintArea().SSize() );
+        pLower->ChgSize( getFramePrintArea().SSize() );
         return;
     }
 
@@ -328,7 +332,7 @@ void SwLayoutFrame::AdjustColumns( const SwFormatCol 
*pAttr, bool bAdjustAttribu
         if ( !bAdjustAttributes )
         {
             tools::Long nAvail = fnRect.GetWidth(getFramePrintArea());
-            for ( SwLayoutFrame *pCol = static_cast<SwLayoutFrame*>(Lower());
+            for ( SwLayoutFrame *pCol = static_cast<SwLayoutFrame*>(pLower);
                   pCol;
                   pCol = static_cast<SwLayoutFrame*>(pCol->GetNext()) )
                 nAvail -= fnRect.GetWidth(pCol->getFrameArea());
@@ -344,7 +348,7 @@ void SwLayoutFrame::AdjustColumns( const SwFormatCol 
*pAttr, bool bAdjustAttribu
     const sal_uInt16 nMin = bLine ? sal_uInt16( 20 + ( pAttr->GetLineWidth() / 
2) ) : 0;
 
     const bool bR2L = IsRightToLeft();
-    SwFrame *pCol = bR2L ? GetLastLower() : Lower();
+    SwFrame *pCol = bR2L ? GetLastLower() : pLower;
 
     // #i27399#
     // bOrtho means we have to adjust the column frames manually. Otherwise
@@ -429,7 +433,7 @@ void SwLayoutFrame::AdjustColumns( const SwFormatCol 
*pAttr, bool bAdjustAttribu
         return;
 
     tools::Long nInnerWidth = ( nAvail - nGutter ) / pAttr->GetNumCols();
-    pCol = Lower();
+    pCol = pLower;
     for( sal_uInt16 i = 0; i < pAttr->GetNumCols() && pCol; pCol = 
pCol->GetNext(), ++i ) //i118878, value returned by GetNumCols() can't be 
trusted
     {
         SwTwips nWidth;

Reply via email to