diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-03-29 09:11:33 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-03-29 12:44:50 +0200 |
commit | 8d1de00d3efb0f772b1c64c315bd337601b14d91 (patch) | |
tree | 449230e5f9e8b3a2372fd97e1dbdb2cff7942fa8 /lotuswordpro | |
parent | 980248e4926b7d24c197084038337e4868badb9c (diff) |
lwp infinite loop
Change-Id: Ic384dfd66f834ee360c60e497b8b7b688c913f02
Reviewed-on: https://gerrit.libreoffice.org/52057
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'lotuswordpro')
-rw-r--r-- | lotuswordpro/source/filter/lwpdoc.cxx | 17 |
1 files changed, 9 insertions, 8 deletions
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<LwpDocument*> 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<LwpDocument*> 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; |