sw/source/core/draw/dflyobj.cxx    |    4 ++--
 sw/source/core/inc/flyfrm.hxx      |    2 +-
 sw/source/core/layout/paintfrm.cxx |   16 +++++++---------
 sw/source/core/text/porfly.cxx     |    2 +-
 sw/source/core/view/viewimp.cxx    |    2 +-
 5 files changed, 12 insertions(+), 14 deletions(-)

New commits:
commit e90ebdde4110ea7e250f66327af1e3f4eeb8718f
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Wed Dec 4 08:49:15 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Wed Dec 4 13:29:36 2024 +0100

    cid#1636561 Dereference after null check
    
    Change-Id: I7a4c19d9344dba9c09861fe78b864a8651c3286f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177771
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 29a818a52847..9b6ffb4b2939 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -509,12 +509,12 @@ void SwVirtFlyDrawObj::wrap_DoPaintObject(
     // but no paints. IsPaintInProgress() depends on SW repaint, so, as long
     // as SW paints self and calls DrawLayer() for Heaven and Hell, this will
     // be correct
-    if ( !(pShell && pShell->IsDrawingLayerPaintInProgress()) )
+    if (!pShell || !pShell->IsDrawingLayerPaintInProgress())
         return;
 
     bool bDrawObject(true);
 
-    if ( !SwFlyFrame::IsPaint( const_cast<SwVirtFlyDrawObj*>(this), pShell ) )
+    if ( !SwFlyFrame::IsPaint( const_cast<SwVirtFlyDrawObj*>(this), *pShell ) )
     {
         bDrawObject = false;
     }
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index 31821741c85b..bbad4462bee2 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -242,7 +242,7 @@ public:
                      const bool _bForPaint = false ) const;
 
     // Paint on this shell (consider Preview, print flag, etc. recursively)?
-    static bool IsPaint( SdrObject *pObj, const SwViewShell *pSh );
+    static bool IsPaint(SdrObject *pObj, const SwViewShell& rSh);
 
     /** SwFlyFrame::IsBackgroundTransparent
 
diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index e8188f77f7f5..68486df83780 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -4101,20 +4101,19 @@ static void lcl_PaintReplacement( const SwRect &rRect, 
const SwViewShell &rSh )
     Graphic::DrawEx(*rSh.GetOut(), OUString(), aFont, rBmp, rRect.Pos(), 
rRect.SSize());
 }
 
-bool SwFlyFrame::IsPaint( SdrObject *pObj, const SwViewShell *pSh )
+bool SwFlyFrame::IsPaint(SdrObject *pObj, const SwViewShell& rSh)
 {
     SdrObjUserCall *pUserCall = GetUserCall(pObj);
 
     if ( nullptr == pUserCall )
         return true;
 
-    if ( pSh && ((!pSh->GetViewOptions()->IsDraw()
+    if ( (!rSh.GetViewOptions()->IsDraw()
              && (dynamic_cast<SdrUnoObj*>(pObj) || 
dynamic_cast<SdrAttrObj*>(pObj) || dynamic_cast<SwFlyDrawObj*>(pObj)))
-        || (!pSh->GetViewOptions()->IsGraphic() && 
dynamic_cast<SwVirtFlyDrawObj*>(pObj)) )
-         )
+        || (!rSh.GetViewOptions()->IsGraphic() && 
dynamic_cast<SwVirtFlyDrawObj*>(pObj)) )
     {
         SwRect rBoundRect = GetBoundRectOfAnchoredObj( pObj );
-        lcl_PaintReplacement( rBoundRect, *pSh );
+        lcl_PaintReplacement(rBoundRect, rSh);
         return false;
     }
     assert(pObj);
@@ -4123,7 +4122,7 @@ bool SwFlyFrame::IsPaint( SdrObject *pObj, const 
SwViewShell *pSh )
     bool bPaint =  gProp.pSFlyOnlyDraw ||
                        
static_cast<SwContact*>(pUserCall)->GetFormat()->GetPrint().GetValue();
     if ( !bPaint )
-        bPaint = pSh->GetWin() && !pSh->IsPreview();
+        bPaint = rSh.GetWin() && !rSh.IsPreview();
 
     if ( bPaint )
     {
@@ -4160,7 +4159,7 @@ bool SwFlyFrame::IsPaint( SdrObject *pObj, const 
SwViewShell *pSh )
             {
                 if ( !pAnch->isFrameAreaPositionValid() )
                     pAnch = nullptr;
-                else if ( pSh->GetOut() == 
pSh->getIDocumentDeviceAccess().getPrinter( false ))
+                else if ( rSh.GetOut() == 
rSh.getIDocumentDeviceAccess().getPrinter( false ))
                 {
                     //HACK: we have to omit some of the objects for printing,
                     //otherwise they would be printed twice.
@@ -4183,8 +4182,7 @@ bool SwFlyFrame::IsPaint( SdrObject *pObj, const 
SwViewShell *pSh )
         if ( pAnch )
         {
             if ( pAnch->IsInFly() )
-                bPaint = SwFlyFrame::IsPaint( 
pAnch->FindFlyFrame()->GetVirtDrawObj(),
-                                            pSh );
+                bPaint = 
SwFlyFrame::IsPaint(pAnch->FindFlyFrame()->GetVirtDrawObj(), rSh);
             else if ( gProp.pSFlyOnlyDraw )
                 bPaint = false;
         }
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index ac0c96590f93..d4612cbd26d0 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -225,7 +225,7 @@ void sw::FlyContentPortion::Paint(const SwTextPaintInfo& 
rInf) const
 
     if(!((m_pFly->IsCompletePaint() ||
             m_pFly->getFrameArea().Overlaps(aRepaintRect)) &&
-            SwFlyFrame::IsPaint(m_pFly->GetVirtDrawObj(), 
m_pFly->getRootFrame()->GetCurrShell())))
+            SwFlyFrame::IsPaint(m_pFly->GetVirtDrawObj(), 
*m_pFly->getRootFrame()->GetCurrShell())))
         return;
 
     SwRect aRect(m_pFly->getFrameArea());
diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx
index 73ddbac03b84..dd3aeb3d86a3 100644
--- a/sw/source/core/view/viewimp.cxx
+++ b/sw/source/core/view/viewimp.cxx
@@ -537,7 +537,7 @@ void 
SwViewObjectContactRedirector::createRedirectedPrimitive2DSequence(
     SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject();
     if ( pObj )
     {
-        bPaint = SwFlyFrame::IsPaint( pObj, &mrViewShell );
+        bPaint = SwFlyFrame::IsPaint(pObj, mrViewShell);
     }
 
     if ( !bPaint )

Reply via email to