From 8d1de00d3efb0f772b1c64c315bd337601b14d91 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 29 Mar 2018 09:11:33 +0100 Subject: lwp infinite loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic384dfd66f834ee360c60e497b8b7b688c913f02 Reviewed-on: https://gerrit.libreoffice.org/52057 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- lotuswordpro/source/filter/lwpdoc.cxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lotuswordpro') diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx index 728df2e413b8..77dae05e68dc 100644 --- a/lotuswordpro/source/filter/lwpdoc.cxx +++ b/lotuswordpro/source/filter/lwpdoc.cxx @@ -628,14 +628,15 @@ LwpDocument* LwpDocument::GetLastDivisionWithContents() LwpDocument* LwpDocument::GetRootDocument() { LwpDocument* pRoot = this; - while(pRoot) + std::set aSeen; + while (pRoot) { + aSeen.insert(pRoot); if(!pRoot->IsChildDoc()) return pRoot; - LwpDocument* pNextRoot = pRoot->GetParentDivision(); - if (pNextRoot == pRoot) - throw std::runtime_error("loop in ParentDivision"); - pRoot = pNextRoot; + pRoot = pRoot->GetParentDivision(); + if (aSeen.find(pRoot) != aSeen.end()) + throw std::runtime_error("loop in conversion"); } return nullptr; } @@ -670,12 +671,12 @@ LwpDocument* LwpDocument::GetLastDivisionWithContents() std::set aSeen; while (pLastDoc) { - if (aSeen.find(pLastDoc) != aSeen.end()) - throw std::runtime_error("loop in conversion"); + aSeen.insert(pLastDoc); if (pLastDoc->GetEnSuperTableLayout().is()) return pLastDoc; pLastDoc = pLastDoc->GetPreviousDivisionWithContents(); - aSeen.insert(pLastDoc); + if (aSeen.find(pLastDoc) != aSeen.end()) + throw std::runtime_error("loop in conversion"); } return nullptr; -- cgit