diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-08-25 17:42:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-08-26 09:56:08 +0200 |
commit | b67f42c4c2906b7059b93d748c8efccd588b1e1c (patch) | |
tree | 5391d1f531a75b3ba8873dda3b0ee71122d8b479 /lotuswordpro/source | |
parent | 79c9d11d7ae2272f4190292757fef3803c722317 (diff) |
ofz#35646 Indirect-leak
Change-Id: Ie79d9c49b6beef04ab111a63166abc7f093ad36b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121041
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'lotuswordpro/source')
-rw-r--r-- | lotuswordpro/source/filter/xfilter/xfcell.cxx | 2 | ||||
-rw-r--r-- | lotuswordpro/source/filter/xfilter/xftable.cxx | 32 |
2 files changed, 32 insertions, 2 deletions
diff --git a/lotuswordpro/source/filter/xfilter/xfcell.cxx b/lotuswordpro/source/filter/xfilter/xfcell.cxx index bbfde6eab9f3..dfc5889db652 100644 --- a/lotuswordpro/source/filter/xfilter/xfcell.cxx +++ b/lotuswordpro/source/filter/xfilter/xfcell.cxx @@ -157,7 +157,7 @@ OUString XFCell::GetCellName() return name; } -void XFCell::ToXml(IXFStream *pStrm) +void XFCell::ToXml(IXFStream *pStrm) { IXFAttrList *pAttrList = pStrm->GetAttrList(); diff --git a/lotuswordpro/source/filter/xfilter/xftable.cxx b/lotuswordpro/source/filter/xfilter/xftable.cxx index 6acb1b21a35f..4326f218b1e2 100644 --- a/lotuswordpro/source/filter/xfilter/xftable.cxx +++ b/lotuswordpro/source/filter/xfilter/xftable.cxx @@ -81,6 +81,30 @@ void XFTable::SetColumnStyle(sal_Int32 col, const OUString& style) m_aColumns[col] = style; } +bool XFTable::ContainsTable(const XFTable* pTable) const +{ + for (auto const& elem : m_aRows) + { + const XFRow *pRow = elem.second.get(); + + for (sal_Int32 i = 0; i < pRow->GetCellCount(); ++i) + { + const XFCell* pCell = pRow->GetCell(i + 1); //starts at 1, not 0 + if (const XFTable* pSubTable = pCell->GetSubTable()) + { + if (pSubTable == pTable) + return true; + if (pTable->ContainsTable(pTable)) + return true; + } + if (pCell->HierarchyContains(pTable)) + return true; + } + } + + return false; +} + void XFTable::AddRow(rtl::Reference<XFRow> const & rRow) { assert(rRow); @@ -88,8 +112,14 @@ void XFTable::AddRow(rtl::Reference<XFRow> const & rRow) for (sal_Int32 i = 0; i < rRow->GetCellCount(); ++i) { XFCell* pFirstCell = rRow->GetCell(i + 1); //starts at 1, not 0 - if (pFirstCell->GetSubTable() == this || pFirstCell->HierarchyContains(this)) + if (const XFTable* pSubTable = pFirstCell->GetSubTable()) + { + if (pSubTable == this || pSubTable->ContainsTable(this)) + throw std::runtime_error("table is a subtable of itself"); + } + if (pFirstCell->HierarchyContains(this)) throw std::runtime_error("table is a subtable of itself"); + } int row = rRow->GetRow(); |