[Libreoffice-commits] core.git: sw/source

Aron Budea (via logerrit) logerrit at kemper.freedesktop.org
Sun Sep 5 06:29:25 UTC 2021


 sw/source/core/docnode/ndsect.cxx |   12 ++++++++----
 sw/source/core/docnode/ndtbl.cxx  |   12 ++++++++----
 sw/source/core/docnode/node.cxx   |    6 ++++--
 sw/source/core/layout/frmtool.cxx |   18 ++++++++++++------
 sw/source/core/text/frmform.cxx   |    6 ++++--
 5 files changed, 36 insertions(+), 18 deletions(-)

New commits:
commit c36da188cc7c9d89c331deb6326f045b6e9f0ad9
Author:     Aron Budea <aron.budea at collabora.com>
AuthorDate: Sun Sep 5 03:15:49 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Sep 5 08:28:49 2021 +0200

    tdf#144304 Fix crashes from "speedup dynamic_cast to SwTextFrame"
    
    Also preemptively adjust cases where FindNextCnt(true) or
    FindPrevCnt() can be null.
    
    Regressions from 426930d0c4bd6f782a04a92e8a36e92cd65e186f.
    
    Change-Id: Idb91464ecd285f6f5cf2e399c00faa2dfbbd5601
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121662
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index ff7946ed3b3b..d5c9db008116 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -1121,9 +1121,11 @@ void SwSectionNode::MakeFramesForAdjacentContentNode(const SwNodeIndex & rIdx)
                     if ( pViewShell && pViewShell->GetLayout() &&
                          pViewShell->GetLayout()->IsAnyShellAccessible() )
                     {
+                        auto pNext = pNew->FindNextCnt( true );
+                        auto pPrev = pNew->FindPrevCnt();
                         pViewShell->InvalidateAccessibleParaFlowRelation(
-                            pNew->FindNextCnt( true )->DynCastTextFrame(),
-                            pNew->FindPrevCnt()->DynCastTextFrame() );
+                            pNext ? pNext->DynCastTextFrame() : nullptr,
+                            pPrev ? pPrev->DynCastTextFrame() : nullptr );
                     }
                 }
                 pNew = pSct;
@@ -1147,9 +1149,11 @@ void SwSectionNode::MakeFramesForAdjacentContentNode(const SwNodeIndex & rIdx)
                 if ( pViewShell && pViewShell->GetLayout() &&
                      pViewShell->GetLayout()->IsAnyShellAccessible() )
                 {
+                    auto pNext = pNew->FindNextCnt( true );
+                    auto pPrev = pNew->FindPrevCnt();
                     pViewShell->InvalidateAccessibleParaFlowRelation(
-                        pNew->FindNextCnt( true )->DynCastTextFrame(),
-                        pNew->FindPrevCnt()->DynCastTextFrame() );
+                        pNext ? pNext->DynCastTextFrame() : nullptr,
+                        pPrev ? pPrev->DynCastTextFrame() : nullptr );
                 }
             }
             if ( bInitNewSect )
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index c39676570943..89834dc00e9b 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -2432,9 +2432,11 @@ void SwTableNode::MakeOwnFrames(SwNodeIndex* pIdxBehind)
             if ( pViewShell && pViewShell->GetLayout() &&
                  pViewShell->GetLayout()->IsAnyShellAccessible() )
             {
+                auto pNext = pNew->FindNextCnt( true );
+                auto pPrev = pNew->FindPrevCnt();
                 pViewShell->InvalidateAccessibleParaFlowRelation(
-                            pNew->FindNextCnt( true )->DynCastTextFrame(),
-                            pNew->FindPrevCnt()->DynCastTextFrame() );
+                            pNext ? pNext->DynCastTextFrame() : nullptr,
+                            pPrev ? pPrev->DynCastTextFrame() : nullptr );
             }
         }
         pNew->RegistFlys();
@@ -2467,9 +2469,11 @@ void SwTableNode::DelFrames(SwRootFrame const*const pLayout)
                     if ( pViewShell && pViewShell->GetLayout() &&
                          pViewShell->GetLayout()->IsAnyShellAccessible() )
                     {
+                        auto pNext = pFrame->FindNextCnt( true );
+                        auto pPrev = pFrame->FindPrevCnt();
                         pViewShell->InvalidateAccessibleParaFlowRelation(
-                            pFrame->FindNextCnt( true )->DynCastTextFrame(),
-                            pFrame->FindPrevCnt()->DynCastTextFrame() );
+                            pNext ? pNext->DynCastTextFrame() : nullptr,
+                            pPrev ? pPrev->DynCastTextFrame() : nullptr );
                     }
                 }
                 pFrame->Cut();
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index d7a2a6ba7116..1e34abfa4b5f 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1487,9 +1487,11 @@ void SwContentNode::DelFrames(SwRootFrame const*const pLayout)
             if ( pViewShell && pViewShell->GetLayout() &&
                  pViewShell->GetLayout()->IsAnyShellAccessible() )
             {
+                auto pNext = pFrame->FindNextCnt( true );
+                auto pPrev = pFrame->FindPrevCnt();
                 pViewShell->InvalidateAccessibleParaFlowRelation(
-                            pFrame->FindNextCnt( true )->DynCastTextFrame(),
-                            pFrame->FindPrevCnt()->DynCastTextFrame() );
+                            pNext ? pNext->DynCastTextFrame() : nullptr,
+                            pPrev ? pPrev->DynCastTextFrame() : nullptr );
             }
         }
 
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 77293c14d270..7d4eb1f2496c 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -1588,9 +1588,11 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc,
                      pViewShell->GetLayout()->IsAnyShellAccessible() &&
                      pFrame->FindPageFrame() != nullptr)
                 {
+                    auto pNext = pFrame->FindNextCnt( true );
+                    auto pPrev = pFrame->FindPrevCnt();
                     pViewShell->InvalidateAccessibleParaFlowRelation(
-                        pFrame->FindNextCnt( true )->DynCastTextFrame(),
-                        pFrame->FindPrevCnt()->DynCastTextFrame() );
+                        pNext ? pNext->DynCastTextFrame() : nullptr,
+                        pPrev ? pPrev->DynCastTextFrame() : nullptr );
                     // #i68958#
                     // The information flags of the text frame are validated
                     // in methods <FindNextCnt(..)> and <FindPrevCnt(..)>.
@@ -1674,9 +1676,11 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc,
                      pViewShell->GetLayout()->IsAnyShellAccessible() &&
                      pFrame->FindPageFrame() != nullptr)
                 {
+                    auto pNext = pFrame->FindNextCnt( true );
+                    auto pPrev = pFrame->FindPrevCnt();
                     pViewShell->InvalidateAccessibleParaFlowRelation(
-                            pFrame->FindNextCnt( true )->DynCastTextFrame(),
-                            pFrame->FindPrevCnt()->DynCastTextFrame() );
+                            pNext ? pNext->DynCastTextFrame() : nullptr,
+                            pPrev ? pPrev->DynCastTextFrame() : nullptr );
                 }
             }
             if ( bObjsDirect && !pTable->empty() )
@@ -1786,9 +1790,11 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc,
                          pViewShell->GetLayout()->IsAnyShellAccessible() &&
                          pFrame->FindPageFrame() != nullptr)
                     {
+                        auto pNext = pFrame->FindNextCnt( true );
+                        auto pPrev = pFrame->FindPrevCnt();
                         pViewShell->InvalidateAccessibleParaFlowRelation(
-                            pFrame->FindNextCnt( true )->DynCastTextFrame(),
-                            pFrame->FindPrevCnt()->DynCastTextFrame() );
+                            pNext ? pNext->DynCastTextFrame() : nullptr,
+                            pPrev ? pPrev->DynCastTextFrame() : nullptr );
                     }
                 }
                 pFrame->CheckDirChange();
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index b0ded2d75306..4731a7d99ebd 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -668,8 +668,9 @@ SwContentFrame *SwTextFrame::JoinFrame()
         if ( pViewShell && pViewShell->GetLayout() &&
              pViewShell->GetLayout()->IsAnyShellAccessible() )
         {
+            auto pNext = pFoll->FindNextCnt( true );
             pViewShell->InvalidateAccessibleParaFlowRelation(
-                            pFoll->FindNextCnt( true )->DynCastTextFrame(),
+                            pNext ? pNext->DynCastTextFrame() : nullptr,
                             this );
         }
     }
@@ -702,8 +703,9 @@ void SwTextFrame::SplitFrame(TextFrameIndex const nTextPos)
         if ( pViewShell && pViewShell->GetLayout() &&
              pViewShell->GetLayout()->IsAnyShellAccessible() )
         {
+            auto pNext = pNew->FindNextCnt( true );
             pViewShell->InvalidateAccessibleParaFlowRelation(
-                            pNew->FindNextCnt( true )->DynCastTextFrame(),
+                            pNext ? pNext->DynCastTextFrame() : nullptr,
                             this );
         }
     }


More information about the Libreoffice-commits mailing list