diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-02-08 11:34:15 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-02-08 21:52:17 +0100 |
commit | faef7e6f89da31040c3a1f51cfa2356e8711935f (patch) | |
tree | 310572ed815c1efbbb910582e170107da1bff642 /lotuswordpro/source | |
parent | 7116b9cc2f3ee28b4444540d0c14183b9bd17968 (diff) |
infinite regress
Change-Id: I7f716d2273115284769d580165fbfa21c1db541b
Reviewed-on: https://gerrit.libreoffice.org/49422
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'lotuswordpro/source')
-rw-r--r-- | lotuswordpro/source/filter/lwpdoc.cxx | 24 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwpdoc.hxx | 1 |
2 files changed, 15 insertions, 10 deletions
diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx index 27db9a01978d..7a0165191daf 100644 --- a/lotuswordpro/source/filter/lwpdoc.cxx +++ b/lotuswordpro/source/filter/lwpdoc.cxx @@ -74,6 +74,7 @@ LwpDocument::LwpDocument(LwpObjectHeader const & objHdr, LwpSvStream* pStrm) : LwpDLNFPVList(objHdr, pStrm) , m_pOwnedFoundry(nullptr) , m_bGettingFirstDivisionWithContentsThatIsNotOLE(false) + , m_bGettingPreviousDivisionWithContents(false) , m_nFlags(0) , m_nPersistentFlags(0) , m_pLnOpts(nullptr) @@ -526,17 +527,20 @@ LwpDocument* LwpDocument::GetPreviousDivision() /** * @descr Get previous division which has contents, copy from lwp source code */ - LwpDocument* LwpDocument::GetPreviousDivisionWithContents() +LwpDocument* LwpDocument::GetPreviousDivisionWithContents() { - if(GetPreviousDivision()) - { - LwpDocument* pDoc = GetPreviousDivision()->GetLastDivisionWithContents(); - if (pDoc) - return pDoc; - } - if(GetParentDivision()) - return GetParentDivision()->GetPreviousDivisionWithContents(); - return nullptr; + if (m_bGettingPreviousDivisionWithContents) + throw std::runtime_error("recursion in page divisions"); + m_bGettingPreviousDivisionWithContents = true; + LwpDocument* pRet = nullptr; + + if (GetPreviousDivision()) + pRet = GetPreviousDivision()->GetLastDivisionWithContents(); + if (!pRet && GetParentDivision()) + pRet = GetParentDivision()->GetPreviousDivisionWithContents(); + + m_bGettingPreviousDivisionWithContents = false; + return pRet; } /** * @descr Get last division which has contents, copy from lwp source code diff --git a/lotuswordpro/source/filter/lwpdoc.hxx b/lotuswordpro/source/filter/lwpdoc.hxx index 03b7c143afc6..4f9b8f9ac56f 100644 --- a/lotuswordpro/source/filter/lwpdoc.hxx +++ b/lotuswordpro/source/filter/lwpdoc.hxx @@ -85,6 +85,7 @@ public: private: LwpFoundry* m_pOwnedFoundry; bool m_bGettingFirstDivisionWithContentsThatIsNotOLE; + bool m_bGettingPreviousDivisionWithContents; //Data members in file format LwpObjectID m_DocSockID; |