summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-11-16 13:08:48 +0100
committerMichael Stahl <michael.stahl@cib.de>2020-11-16 16:50:41 +0100
commit094ee3955ee81e1bc631d50cc216cbb17a777839 (patch)
tree46c822440bc82ab01c9341164f29031b02a4b0a5
parent0d071acc0bd422e6d9af14cc7d7f35b6b3356478 (diff)
(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@cib.de>
-rw-r--r--sw/source/core/layout/layact.cxx20
1 files changed, 12 insertions, 8 deletions
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 2195829f06ed..45ac680c8f4f 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -447,15 +447,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;