[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Wed May 19 08:43:46 UTC 2021


 sw/source/core/layout/layact.cxx |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

New commits:
commit 9845172aff75d6a53a4c7cb212dfeeb37b7eb625
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Nov 16 13:08:48 2020 +0100
Commit:     Michael Stahl <michael.stahl at allotropia.de>
CommitDate: Wed May 19 10:43:14 2021 +0200

    (related tdf#134298) sw: layout: avoid infinite loop in InternalAction()
    
    The condition IsInterrupt() && pPage && (m_nCheckPageNum != USHRT_MAX)
    isn't handled properly and the while loop will never terminate with
    the fix for tdf#134298 in several UITest_writer_tests*.
    
    If m_nCheckPageNum is set, then it must result in a call to
    CheckPageDescs() here; it's a member of SwLayAction so won't survive
    until the next idle layout invocation.
    
    There is a funny history of these loop conditions with
    commit 9eff9e699e17cc5a8a25895bd28dc8e4ceb8071e
    and cee296066ab780217395201ab84c2150c8840d25 so we can only hope
    this time we got it right...
    
    Change-Id: I91b63540bf4280296d747cb8e841594f8dd3b140
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105927
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 094ee3955ee81e1bc631d50cc216cbb17a777839)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114096
    Tested-by: Michael Stahl <michael.stahl at allotropia.de>
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>

diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 04201e1c6f5e..90d2eed2b1ff 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -448,15 +448,19 @@ void SwLayAction::InternalAction(OutputDevice* pRenderContext)
     sal_uInt16 nPercentPageNum = 0;
     while ((!IsInterrupt() && pPage) || (m_nCheckPageNum != USHRT_MAX))
     {
-        if (!pPage && m_nCheckPageNum != USHRT_MAX)
+        // note: this is the only place that consumes and resets m_nCheckPageNum
+        if ((IsInterrupt() || !pPage) && m_nCheckPageNum != USHRT_MAX)
         {
-            SwPageFrame *pPg = static_cast<SwPageFrame*>(m_pRoot->Lower());
-            while (pPg && pPg->GetPhyPageNum() < m_nCheckPageNum)
-                pPg = static_cast<SwPageFrame*>(pPg->GetNext());
-            if (pPg)
-                pPage = pPg;
-            if (!pPage)
-                break;
+            if (!pPage || m_nCheckPageNum < pPage->GetPhyPageNum())
+            {
+                SwPageFrame *pPg = static_cast<SwPageFrame*>(m_pRoot->Lower());
+                while (pPg && pPg->GetPhyPageNum() < m_nCheckPageNum)
+                    pPg = static_cast<SwPageFrame*>(pPg->GetNext());
+                if (pPg)
+                    pPage = pPg;
+                if (!pPage)
+                    break;
+            }
 
             SwPageFrame *pTmp = pPage->GetPrev() ?
                                         static_cast<SwPageFrame*>(pPage->GetPrev()) : pPage;


More information about the Libreoffice-commits mailing list