lotuswordpro/source/filter/lwpdoc.cxx | 42 +++++++++++++++++++++------------- lotuswordpro/source/filter/lwpdoc.hxx | 1 2 files changed, 27 insertions(+), 16 deletions(-)
New commits: commit b083916a51f267e728c24f827263387c4c52df3a Author: Caolán McNamara <caol...@redhat.com> Date: Sun Feb 11 14:33:30 2018 +0000 ofz#6225 Infinite recursion Change-Id: I5d5a3ac668baa78aed77d199b65e817975e68928 Reviewed-on: https://gerrit.libreoffice.org/49562 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> 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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits