sw/source/core/text/txtfly.cxx |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit d2d9af865880d5da94e86f40d18686433ff821df
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Dec 27 13:13:45 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Dec 27 15:20:45 2024 +0100

    sw: fix UBSAN build
    
    /sw/source/core/text/txtfly.cxx:181:29: runtime error: downcast of address 
0x6130003eea10 which does not point to an object of type 'const SwFlyFrame'
    0x6130003eea10: note: object has invalid vptr
     be be be be  be be be be be be be be  be be be be be be be be  be be be be 
be be be be  be be be be
                  ^~~~~~~~~~~~~~~~~~~~~~~
                  invalid vptr
    
    Change-Id: I43e25626af82bb9fc3bef4bb9f60dd8aabc10596
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179442
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index 8f7af91704e4..9c47224cdfc5 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -178,10 +178,11 @@ SwRect SwContourCache::CalcBoundRect( const 
SwAnchoredObject* pAnchoredObj,
         }
     }
 
-    const SwFrame* pLower = static_cast<const 
SwFlyFrame*>(pAnchoredObj)->Lower();
+    const SwFlyFrame* pFlyFrame = pAnchoredObj->DynCastFlyFrame();
+    const SwFrame* pLower = pFlyFrame
+        ? static_cast<const SwFlyFrame*>(pAnchoredObj)->Lower() : nullptr;
     if( bHandleContour &&
-        ( pAnchoredObj->DynCastFlyFrame() ==  nullptr ||
-          ( pLower && pLower->IsNoTextFrame() ) ) )
+        ( !pFlyFrame || ( pLower && pLower->IsNoTextFrame() ) ) )
     {
         aRet = pAnchoredObj->GetObjRectWithSpaces();
         if( aRet.Overlaps( rLine ) )

Reply via email to