From 68cebacac864da199ace7fe03db0e054e6b36966 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 18 Feb 2018 21:06:33 +0000 Subject: ofz#6448 infinite-regress MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie0c082a4b43355e935594f2dda694edfc9cdf315 Reviewed-on: https://gerrit.libreoffice.org/49950 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- lotuswordpro/source/filter/lwplayout.cxx | 29 +++++++++++++++-------------- lotuswordpro/source/filter/lwplayout.hxx | 1 + 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'lotuswordpro') diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx index b18896468f22..df43d93a81e2 100644 --- a/lotuswordpro/source/filter/lwplayout.cxx +++ b/lotuswordpro/source/filter/lwplayout.cxx @@ -1424,6 +1424,7 @@ bool LwpMiddleLayout::HasContent() LwpLayout::LwpLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm) : LwpMiddleLayout(objHdr, pStrm) , m_bGettingShadow(false) + , m_bGettingNumCols(false) { } @@ -1472,24 +1473,24 @@ void LwpLayout::Read() */ sal_uInt16 LwpLayout::GetNumCols() { - if(m_nOverrideFlag & OVER_COLUMNS) + if (m_bGettingNumCols) + throw std::runtime_error("recursion in layout"); + m_bGettingNumCols = true; + + sal_uInt16 nRet = 0; + LwpLayoutColumns* pLayColumns = (m_nOverrideFlag & OVER_COLUMNS) ? dynamic_cast(m_LayColumns.obj().get()) : nullptr; + if (pLayColumns) { - LwpLayoutColumns* pLayColumns = dynamic_cast(m_LayColumns.obj().get()); - if(pLayColumns) - { - return pLayColumns->GetNumCols(); - } + nRet = pLayColumns->GetNumCols(); } - - rtl::Reference xBase(GetBasedOnStyle()); - LwpVirtualLayout* pStyle = dynamic_cast(xBase.get()); - if (pStyle) + else { - return pStyle->GetNumCols(); + rtl::Reference xBase(GetBasedOnStyle()); + LwpVirtualLayout* pStyle = dynamic_cast(xBase.get()); + nRet = pStyle ? pStyle->GetNumCols() : LwpVirtualLayout::GetNumCols(); } - - return LwpVirtualLayout::GetNumCols(); - + m_bGettingNumCols = false; + return nRet; } /** diff --git a/lotuswordpro/source/filter/lwplayout.hxx b/lotuswordpro/source/filter/lwplayout.hxx index a0f6ef868da3..50dbcdf57197 100644 --- a/lotuswordpro/source/filter/lwplayout.hxx +++ b/lotuswordpro/source/filter/lwplayout.hxx @@ -417,6 +417,7 @@ class LwpLayout : public LwpMiddleLayout { private: bool m_bGettingShadow; + bool m_bGettingNumCols; public: LwpLayout( LwpObjectHeader const &objHdr, LwpSvStream* pStrm ); virtual ~LwpLayout() override; -- cgit