lotuswordpro/qa/cppunit/data/fail/recurse-5.lwp |binary lotuswordpro/source/filter/lwpcelllayout.cxx | 15 +++++++++++++-- lotuswordpro/source/filter/lwpcelllayout.hxx | 8 +++++--- lotuswordpro/source/filter/lwprowlayout.cxx | 6 +++--- lotuswordpro/source/filter/lwptablelayout.cxx | 2 +- 5 files changed, 22 insertions(+), 9 deletions(-)
New commits: commit 21f9812eb53272d50522a649b8c4b3492d95450b Author: Caolán McNamara <caol...@redhat.com> Date: Mon Apr 30 15:31:51 2018 +0100 ofz#8095 avoid recurse to death Reviewed-on: https://gerrit.libreoffice.org/53663 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 25c0988b87b71f93577837f4a300f5f17366d145) Change-Id: I0acb0f68f64bb95a4510a330d463badd2cf8a84a Reviewed-on: https://gerrit.libreoffice.org/53668 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Michael Stahl <michael.st...@cib.de> diff --git a/lotuswordpro/qa/cppunit/data/fail/recurse-5.lwp b/lotuswordpro/qa/cppunit/data/fail/recurse-5.lwp new file mode 100644 index 000000000000..a81b42f61e95 Binary files /dev/null and b/lotuswordpro/qa/cppunit/data/fail/recurse-5.lwp differ diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx index 504ccb366b73..93e71fd88255 100644 --- a/lotuswordpro/source/filter/lwpcelllayout.cxx +++ b/lotuswordpro/source/filter/lwpcelllayout.cxx @@ -74,8 +74,19 @@ #include <xfilter/xfcellstyle.hxx> #include <xfilter/xfcolstyle.hxx> +rtl::Reference<XFCell> LwpCellLayout::DoConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol) +{ + if (m_bConvertCell) + throw std::runtime_error("recursion in page divisions"); + m_bConvertCell = true; + rtl::Reference<XFCell> aRet = ConvertCell(aTableID, nRow, nCol); + m_bConvertCell = false; + return aRet; +} + LwpCellLayout::LwpCellLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm) : LwpMiddleLayout(objHdr, pStrm) + , m_bConvertCell(false) , crowid(0) , ccolid(0) , cType(LDT_NONE) @@ -890,11 +901,11 @@ rtl::Reference<XFCell> LwpHiddenCellLayout::ConvertCell(LwpObjectID aTableID, sa LwpCellLayout *pDefault = dynamic_cast<LwpCellLayout *>(pTable->GetDefaultCellStyle().obj().get()); if (pDefault) { - xXFCell = pDefault->ConvertCell(aTableID, nRow, nCol); + xXFCell = pDefault->DoConvertCell(aTableID, nRow, nCol); } else { - xXFCell = pConnCell->ConvertCell(aTableID, nRow, nCol); + xXFCell = pConnCell->DoConvertCell(aTableID, nRow, nCol); } xXFCell->SetColumnSpaned(pConnCell->GetNumcols()); } diff --git a/lotuswordpro/source/filter/lwpcelllayout.hxx b/lotuswordpro/source/filter/lwpcelllayout.hxx index 4969f568e9a1..907c29f8cf50 100644 --- a/lotuswordpro/source/filter/lwpcelllayout.hxx +++ b/lotuswordpro/source/filter/lwpcelllayout.hxx @@ -89,7 +89,7 @@ public: LwpCellLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm); virtual ~LwpCellLayout() override; virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_CELL_LAYOUT;} - virtual rtl::Reference<XFCell> ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol); + rtl::Reference<XFCell> DoConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol); sal_uInt16 GetRowID(){return crowid;} sal_uInt8 GetColID(){return ccolid;} void RegisterStyle() override; @@ -114,10 +114,12 @@ protected: OUString const & GetCellStyleName(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout); void RegisterDefaultCell(); virtual LwpCellBorderType GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout); + virtual rtl::Reference<XFCell> ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol); static LwpCellLayout * GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout); static sal_uInt16 GetLeftColID(sal_uInt16 nCol){return nCol - 1; }; virtual sal_uInt16 GetBelowRowID(sal_uInt16 nRow){return nRow + 1; }; + bool m_bConvertCell; sal_uInt16 crowid; sal_uInt8 ccolid; LwpObjectID cLayNumerics; @@ -147,11 +149,11 @@ public: virtual ~LwpHiddenCellLayout() override; virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_HIDDEN_CELL_LAYOUT;} virtual void Parse(IXFStream* pOutputStream) override; - virtual rtl::Reference<XFCell> ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol) override; void RegisterStyle() override {} virtual void SetCellMap() override; private: void Read() override; + virtual rtl::Reference<XFCell> ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol) override; LwpObjectID cconnectedlayout; }; @@ -166,7 +168,6 @@ public: virtual ~LwpConnectedCellLayout() override; virtual LWP_LAYOUT_TYPE GetLayoutType () override { return LWP_CONNECTED_CELL_LAYOUT;} virtual void Parse(IXFStream* pOutputStream) override; - virtual rtl::Reference<XFCell> ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol) override; sal_uInt16 GetNumrows(){return m_nRealrowspan;} sal_uInt8 GetNumcols(){return m_nRealcolspan;} virtual void SetCellMap() override; @@ -175,6 +176,7 @@ protected: void Read() override; virtual sal_uInt16 GetBelowRowID(sal_uInt16 nRow) override {return nRow + m_nRealrowspan; }; virtual LwpCellBorderType GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout) override; + virtual rtl::Reference<XFCell> ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol) override; sal_uInt16 cnumrows; sal_uInt8 cnumcols; sal_uInt16 m_nRealrowspan; diff --git a/lotuswordpro/source/filter/lwprowlayout.cxx b/lotuswordpro/source/filter/lwprowlayout.cxx index f80adffb20ec..74228d8df9f6 100644 --- a/lotuswordpro/source/filter/lwprowlayout.cxx +++ b/lotuswordpro/source/filter/lwprowlayout.cxx @@ -221,7 +221,7 @@ void LwpRowLayout::ConvertRow(rtl::Reference<XFTable> const & pXFTable,sal_uInt8 { sal_uInt8 nColID = m_ConnCellList[nMarkConnCell]->GetColID() +m_ConnCellList[nMarkConnCell]->GetNumcols()-1; - xXFCell = m_ConnCellList[nMarkConnCell]->ConvertCell( + xXFCell = m_ConnCellList[nMarkConnCell]->DoConvertCell( pTable->GetObjectID(), crowid+m_ConnCellList[nMarkConnCell]->GetNumrows()-1, m_ConnCellList[nMarkConnCell]->GetColID()); @@ -391,7 +391,7 @@ void LwpRowLayout::ConvertCommonRow(rtl::Reference<XFTable> const & pXFTable, sa nCellEndCol = i+pConnCell->GetNumcols()-1; i = nCellEndCol; } - xCell = pCellLayout->ConvertCell(pTable->GetObjectID(),crowid,i); + xCell = pCellLayout->DoConvertCell(pTable->GetObjectID(),crowid,i); break; } rCellID = pCellLayout->GetNext(); @@ -404,7 +404,7 @@ void LwpRowLayout::ConvertCommonRow(rtl::Reference<XFTable> const & pXFTable, sa LwpCellLayout * pDefaultCell = pTableLayout->GetDefaultCellLayout(); if (pDefaultCell) { - xCell = pDefaultCell->ConvertCell( + xCell = pDefaultCell->DoConvertCell( pTable->GetObjectID(),crowid, i); } else diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx index de78337ba4b8..f9bfd1d2d06d 100644 --- a/lotuswordpro/source/filter/lwptablelayout.cxx +++ b/lotuswordpro/source/filter/lwptablelayout.cxx @@ -1341,7 +1341,7 @@ void LwpTableLayout::ConvertDefaultRow(rtl::Reference<XFTable> const & pXFTable, rtl::Reference<XFCell> xCell; if (m_pDefaultCellLayout) { - xCell = m_pDefaultCellLayout->ConvertCell( + xCell = m_pDefaultCellLayout->DoConvertCell( GetTable()->GetObjectID(),nRowID,j+nStartCol); } else _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits