summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-09-27 17:25:13 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-09-27 20:23:59 +0200
commit1010c16c5f4c582adfa9d24036e9f98137e5ede7 (patch)
tree957924f176efb2b3e2d3949fe2a52b275043f6f4
parent10c8bd1ed8fbc4cf387803fcb9b70dcfe776b4ab (diff)
ofz#39374: avoid infinite loop
Change-Id: I0aec664279dea99df865761f34f64aa4fa3d9e0d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122725 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--lotuswordpro/source/filter/lwppagelayout.cxx7
1 files changed, 7 insertions, 0 deletions
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
index cc8d6b274360..0a72db8f7d30 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -74,6 +74,7 @@
#include <lwpchangemgr.hxx>
#include <lwpfilehdr.hxx>
#include <lwpglobalmgr.hxx>
+#include <o3tl/sorted_vector.hxx>
#include <sal/log.hxx>
#include <vcl/print.hxx>
@@ -548,8 +549,11 @@ LwpPageLayout* LwpPageLayout::GetOddChildLayout()
{
rtl::Reference<LwpVirtualLayout> xLay(
dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get()));
+ o3tl::sorted_vector<LwpVirtualLayout*> aSeen;
while (xLay.is())
{
+ aSeen.insert(xLay.get());
+
if (xLay->GetLayoutType() == LWP_PAGE_LAYOUT)
{
LwpPageLayout* pPageLayout = static_cast<LwpPageLayout*>(xLay.get());
@@ -560,6 +564,9 @@ LwpPageLayout* LwpPageLayout::GetOddChildLayout()
}
}
xLay.set(dynamic_cast<LwpVirtualLayout*>(xLay->GetNext().obj().get()));
+
+ if (aSeen.find(xLay.get()) != aSeen.end())
+ throw std::runtime_error("loop in conversion");
}
}
return nullptr;