[Libreoffice-commits] core.git: lotuswordpro/inc lotuswordpro/qa lotuswordpro/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 26 07:56:43 UTC 2021
lotuswordpro/inc/xfilter/xftable.hxx | 2 +
lotuswordpro/qa/cppunit/data/fail/ofz35646-1.lwp |binary
lotuswordpro/source/filter/xfilter/xfcell.cxx | 2 -
lotuswordpro/source/filter/xfilter/xftable.cxx | 32 ++++++++++++++++++++++-
4 files changed, 34 insertions(+), 2 deletions(-)
New commits:
commit b67f42c4c2906b7059b93d748c8efccd588b1e1c
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Aug 25 17:42:17 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Aug 26 09:56:08 2021 +0200
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 at redhat.com>
diff --git a/lotuswordpro/inc/xfilter/xftable.hxx b/lotuswordpro/inc/xfilter/xftable.hxx
index f36a1f295be6..ce292f3a258c 100644
--- a/lotuswordpro/inc/xfilter/xftable.hxx
+++ b/lotuswordpro/inc/xfilter/xftable.hxx
@@ -115,6 +115,8 @@ private:
OUString m_strDefCellStyle;
OUString m_strDefRowStyle;
OUString m_strDefColStyle;
+
+ bool ContainsTable(const XFTable* pTable) const;
};
inline void XFTable::SetTableName(const OUString& name)
diff --git a/lotuswordpro/qa/cppunit/data/fail/ofz35646-1.lwp b/lotuswordpro/qa/cppunit/data/fail/ofz35646-1.lwp
new file mode 100644
index 000000000000..5db8cea8c5bd
Binary files /dev/null and b/lotuswordpro/qa/cppunit/data/fail/ofz35646-1.lwp differ
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();
More information about the Libreoffice-commits
mailing list