tdf#151375 sw: ODF import: delete any layout frames before ...
... converting subtables.
This avoids use-after-free by the frames or a11y code on deleted cells.
For file open, there is no layout at this point, but when inserting a
file the crash happens.
(regression from commit e366c928819c44b5c253c45dca6dae40b71c9808)
Change-Id: Ia2cbe548fd5cdce7ae2479bfc3dc993ebb3ce830
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141080
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index 8d6bcf02..a0c420b 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -2382,6 +2382,8 @@ bool SwTable::CanConvertSubtables() const
void SwTable::ConvertSubtables()
{
FndBox_ all(nullptr, nullptr);
all.DelFrames(*this); // tdf#151375 avoid UAF by frames on deleted cells
for (size_t i = 0; i < GetTabLines().size(); ++i)
{
SwTableLine *const pLine(GetTabLines()[i]);
@@ -2397,6 +2399,7 @@ void SwTable::ConvertSubtables()
}
GCLines();
m_bNewModel = true;
all.MakeFrames(*this);
#if 0
// note: outline nodes (and ordinary lists) are sorted by MoveNodes() itself
// (this could change order inside table of contents, but that's a