From 9ec011f6874cf663db54d0420c41d9299e4ed882 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 28 Dec 2015 14:43:50 +0000 Subject: guard against infinite recursion in GetGeometry Change-Id: I901f77f5846512cb528f2e14bbc50409fa29bef2 --- lotuswordpro/source/filter/lwplayout.cxx | 11 +++++++---- lotuswordpro/source/filter/lwplayout.hxx | 12 +++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'lotuswordpro') diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx index 68003a7cad5e..32bc4fda0f98 100644 --- a/lotuswordpro/source/filter/lwplayout.cxx +++ b/lotuswordpro/source/filter/lwplayout.cxx @@ -560,9 +560,12 @@ void LwpLayoutMisc::Read(LwpObjectStream* pStrm) } LwpMiddleLayout::LwpMiddleLayout( LwpObjectHeader &objHdr, LwpSvStream* pStrm ) - : LwpVirtualLayout(objHdr, pStrm), - m_pStyleStuff(new LwpLayoutStyle), m_pMiscStuff(new LwpLayoutMisc) -{} + : LwpVirtualLayout(objHdr, pStrm) + , m_pStyleStuff(new LwpLayoutStyle) + , m_pMiscStuff(new LwpLayoutMisc) + , m_bGettingGeometry(false) +{ +} LwpMiddleLayout::~LwpMiddleLayout() { @@ -637,7 +640,7 @@ rtl::Reference LwpMiddleLayout::GetBasedOnStyle() * @descr: Get the geometry of current layout * */ -LwpLayoutGeometry* LwpMiddleLayout::GetGeometry() +LwpLayoutGeometry* LwpMiddleLayout::Geometry() { if( !m_LayGeometry.IsNull() ) { diff --git a/lotuswordpro/source/filter/lwplayout.hxx b/lotuswordpro/source/filter/lwplayout.hxx index 5e86cafc9723..64598dc89b6c 100644 --- a/lotuswordpro/source/filter/lwplayout.hxx +++ b/lotuswordpro/source/filter/lwplayout.hxx @@ -316,7 +316,15 @@ public: virtual bool MarginsSameAsParent() override; virtual double MarginsValue(const sal_uInt8& nWhichSide) override; virtual double GetExtMarginsValue(const sal_uInt8& nWhichSide) override; - LwpLayoutGeometry* GetGeometry(); + LwpLayoutGeometry* GetGeometry() + { + if (m_bGettingGeometry) + throw std::runtime_error("recursion in layout"); + m_bGettingGeometry = true; + auto pRet = Geometry(); + m_bGettingGeometry = false; + return pRet; + } double GetGeometryHeight(); double GetGeometryWidth(); LwpBorderStuff* GetBorderStuff(); @@ -363,6 +371,7 @@ protected: void Read() override; private: LwpObjectID m_BasedOnStyle; + LwpLayoutGeometry* Geometry(); protected: enum { @@ -381,6 +390,7 @@ protected: LwpObjectID m_LayBorderStuff; LwpObjectID m_LayBackgroundStuff; LwpObjectID m_LayExtBorderStuff; + bool m_bGettingGeometry; public: LwpObjectID& GetContent() { return m_Content; } LwpTabOverride* GetTabOverride(); -- cgit v1.2.3