sw/source/core/draw/dview.cxx    |   31 +++++++++++++++++--------------
 sw/source/core/frmedt/fefly1.cxx |    4 ++--
 2 files changed, 19 insertions(+), 16 deletions(-)

New commits:
commit 79be57a37c5db33dc25f22d90e5fe54cca1e0bd8
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Apr 30 10:07:23 2024 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Thu May 16 19:59:08 2024 +0200

    Fix UBSan failure (part 2)
    
    Introduced by 495b5db74f0db59395ff68bacc8d8ca67595b66e
    "sw: check GetUserCall"
    
    https: //gerrit.libreoffice.org/c/core/+/166824/comments/8db24a41_2f4e7e4e
    Change-Id: Ib6f981aa3055f0d37d0b83e3284842d310fe6ef0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166913
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167002
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 644c5ccf0e40..d6ff8b296908 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -386,7 +386,7 @@ const SwFrameFormat* SwFEShell::IsFlyInFly()
         return nullptr;
 
     SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
-    SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
+    SwContact* pContact = GetUserCall( pObj );
     if (!pContact)
         return nullptr;
 
@@ -400,7 +400,7 @@ const SwFrameFormat* SwFEShell::IsFlyInFly()
         }
         else
         {
-            pFly = pContact->GetAnchorFrame(pObj);
+            pFly = static_cast<SwDrawContact*>(pContact)->GetAnchorFrame(pObj);
         }
 
         OSL_ENSURE( pFly, "IsFlyInFly: Where's my anchor?" );
commit 118bde319d10c54a3a6ee53077740406fb07fc13
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Apr 29 09:54:12 2024 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Thu May 16 19:58:56 2024 +0200

    Fix UBSan failure
    
    Introduced by 495b5db74f0db59395ff68bacc8d8ca67595b66e
    "sw: check GetUserCall"
    
    
https://ci.libreoffice.org/job/lo_ubsan/3154/consoleFull#-1571115798d893063f-7f3d-4b7e-b56f-4e0f225817cd
    Change-Id: Ifc80312890f2e6b82dcc9419b5b7e8bfcd5340a5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166824
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167001
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index 39ecb982c00c..5499dad7c9ca 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -706,13 +706,10 @@ const SwFrame* SwDrawView::CalcAnchor()
         return nullptr;
 
     SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
-    SwDrawContact* pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
-    if (!pContact)
-        return nullptr;
 
     //Search for paragraph bound objects, otherwise only the
     //current anchor. Search only if we currently drag.
-    const SwFrame* pAnch;
+    const SwFrame* pAnch = nullptr;
     tools::Rectangle aMyRect;
     auto pFlyDrawObj = dynamic_cast<SwVirtFlyDrawObj *>( pObj );
     if ( pFlyDrawObj )
@@ -724,13 +721,16 @@ const SwFrame* SwDrawView::CalcAnchor()
     {
         // determine correct anchor position for 'virtual' drawing objects.
         // #i26791#
-        pAnch = pContact->GetAnchorFrame( pObj );
-        if( !pAnch )
+        if (SwDrawContact* pContact = 
static_cast<SwDrawContact*>(GetUserCall(pObj)))
         {
-            pContact->ConnectToLayout();
-            // determine correct anchor position for 'virtual' drawing objects.
-            // #i26791#
             pAnch = pContact->GetAnchorFrame( pObj );
+            if( !pAnch )
+            {
+                pContact->ConnectToLayout();
+                // determine correct anchor position for 'virtual' drawing 
objects.
+                // #i26791#
+                pAnch = pContact->GetAnchorFrame( pObj );
+            }
         }
         aMyRect = pObj->GetSnapRect();
     }
@@ -765,11 +765,14 @@ const SwFrame* SwDrawView::CalcAnchor()
         {
             const SwRect aRect( aPt.getX(), aPt.getY(), 1, 1 );
 
-            if ( pContact->GetAnchorFrame( pObj ) &&
-                 pContact->GetAnchorFrame( pObj )->IsPageFrame() )
-                pAnch = pContact->GetPageFrame();
-            else
-                pAnch = pContact->FindPage( aRect );
+            if (SwDrawContact* pContact = 
static_cast<SwDrawContact*>(GetUserCall(pObj)))
+            {
+                if ( pContact->GetAnchorFrame( pObj ) &&
+                     pContact->GetAnchorFrame( pObj )->IsPageFrame() )
+                    pAnch = pContact->GetPageFrame();
+                else
+                    pAnch = pContact->FindPage( aRect );
+            }
         }
     }
     if( pAnch && !pAnch->IsProtected() )

Reply via email to