summaryrefslogtreecommitdiff
path: root/lotuswordpro
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-02-11 14:33:30 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-02-11 22:08:18 +0100
commitb083916a51f267e728c24f827263387c4c52df3a (patch)
treed8d2e571093172509bd99fe01ae89083276d3f7d /lotuswordpro
parent20a646aeda7e940340b0ab11f243c0f09887e1b3 (diff)
ofz#6225 Infinite recursion
Change-Id: I5d5a3ac668baa78aed77d199b65e817975e68928 Reviewed-on: https://gerrit.libreoffice.org/49562 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'lotuswordpro')
-rw-r--r--lotuswordpro/source/filter/lwpdoc.cxx42
-rw-r--r--lotuswordpro/source/filter/lwpdoc.hxx1
2 files changed, 27 insertions, 16 deletions
diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx
index 9c91ea3bca50..779a98a31855 100644
--- a/lotuswordpro/source/filter/lwpdoc.cxx
+++ b/lotuswordpro/source/filter/lwpdoc.cxx
@@ -75,6 +75,7 @@ LwpDocument::LwpDocument(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)
, m_pOwnedFoundry(nullptr)
, m_bGettingFirstDivisionWithContentsThatIsNotOLE(false)
, m_bGettingPreviousDivisionWithContents(false)
+ , m_bGettingGetLastDivisionWithContents(false)
, m_nFlags(0)
, m_nPersistentFlags(0)
, m_pLnOpts(nullptr)
@@ -546,30 +547,39 @@ LwpDocument* LwpDocument::GetPreviousDivisionWithContents()
m_bGettingPreviousDivisionWithContents = false;
return pRet;
}
- /**
- * @descr Get last division which has contents, copy from lwp source code
- */
- LwpDocument* LwpDocument::GetLastDivisionWithContents()
+
+/**
+* @descr Get last division which has contents, copy from lwp source code
+*/
+LwpDocument* LwpDocument::GetLastDivisionWithContents()
{
- LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID().obj().get());
- if(pDivInfo && pDivInfo->HasContents())
- {
- return this;
- }
+ if (m_bGettingGetLastDivisionWithContents)
+ throw std::runtime_error("recursion in page divisions");
+ m_bGettingGetLastDivisionWithContents = true;
+ LwpDocument* pRet = nullptr;
- LwpDocument* pDivision = GetLastDivision();
+ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(GetDivInfoID().obj().get());
+ if (pDivInfo && pDivInfo->HasContents())
+ pRet = this;
- while (pDivision && pDivision != this)
+ if (!pRet)
{
- LwpDocument* pContentDivision = pDivision->GetLastDivisionWithContents();
- if(pContentDivision)
+ LwpDocument* pDivision = GetLastDivision();
+
+ while (pDivision && pDivision != this)
{
- return pContentDivision;
+ LwpDocument* pContentDivision = pDivision->GetLastDivisionWithContents();
+ if (pContentDivision)
+ {
+ pRet = pContentDivision;
+ break;
+ }
+ pDivision = pDivision->GetPreviousDivision();
}
- pDivision = pDivision->GetPreviousDivision();
}
- return nullptr;
+ m_bGettingGetLastDivisionWithContents = false;
+ return pRet;
}
/**
* @descr Get last division in group which has contents, copy from lwp source code
diff --git a/lotuswordpro/source/filter/lwpdoc.hxx b/lotuswordpro/source/filter/lwpdoc.hxx
index 4f9b8f9ac56f..e8551dcd466e 100644
--- a/lotuswordpro/source/filter/lwpdoc.hxx
+++ b/lotuswordpro/source/filter/lwpdoc.hxx
@@ -86,6 +86,7 @@ private:
LwpFoundry* m_pOwnedFoundry;
bool m_bGettingFirstDivisionWithContentsThatIsNotOLE;
bool m_bGettingPreviousDivisionWithContents;
+ bool m_bGettingGetLastDivisionWithContents;
//Data members in file format
LwpObjectID m_DocSockID;