From b08c480ea439c3496f5a8f10c154af3f183f0049 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 7 Dec 2017 08:56:44 +0000 Subject: ofz#4548 infinite regress in GetUsePrinterSettings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id4505f9a4ddc47f2eb45cb86d46fdd050b007c26 Reviewed-on: https://gerrit.libreoffice.org/46009 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- lotuswordpro/source/filter/lwplayout.cxx | 15 ++++++++++++--- lotuswordpro/source/filter/lwplayout.hxx | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'lotuswordpro') diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx index cdaa7ab7dfa3..30ec9d0a4805 100644 --- a/lotuswordpro/source/filter/lwplayout.cxx +++ b/lotuswordpro/source/filter/lwplayout.cxx @@ -81,6 +81,7 @@ LwpVirtualLayout::LwpVirtualLayout(LwpObjectHeader const &objHdr, LwpSvStream* p , m_bGettingIsProtected(false) , m_bGettingMarginsValue(false) , m_bGettingExtMarginsValue(false) + , m_bGettingUsePrinterSettings(false) , m_nAttributes(0) , m_nAttributes2(0) , m_nAttributes3(0) @@ -1405,19 +1406,27 @@ XFBGImage* LwpMiddleLayout::GetXFBGImage() */ bool LwpMiddleLayout::GetUsePrinterSettings() { + if (m_bGettingUsePrinterSettings) + throw std::runtime_error("recursion in layout"); + m_bGettingUsePrinterSettings = true; + + bool bRet = false; + if(m_nOverrideFlag & OVER_SIZE) { - return (m_nAttributes3 & STYLE3_USEPRINTERSETTINGS) != 0; + bRet = (m_nAttributes3 & STYLE3_USEPRINTERSETTINGS) != 0; } else { rtl::Reference xBase(GetBasedOnStyle()); if (LwpMiddleLayout* pLay = dynamic_cast(xBase.get())) { - return pLay->GetUsePrinterSettings(); + bRet = pLay->GetUsePrinterSettings(); } } - return false; + + m_bGettingUsePrinterSettings = false; + return bRet; } //Check whether there are contents in the layout diff --git a/lotuswordpro/source/filter/lwplayout.hxx b/lotuswordpro/source/filter/lwplayout.hxx index efff5f62fd07..cd84af5b380b 100644 --- a/lotuswordpro/source/filter/lwplayout.hxx +++ b/lotuswordpro/source/filter/lwplayout.hxx @@ -226,6 +226,7 @@ protected: bool m_bGettingIsProtected; bool m_bGettingMarginsValue; bool m_bGettingExtMarginsValue; + bool m_bGettingUsePrinterSettings; sal_uInt32 m_nAttributes; sal_uInt32 m_nAttributes2; sal_uInt32 m_nAttributes3; -- cgit