From 8f81535faf6a5d80d5e4d522768c7537e0ca5d21 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 22 Jan 2022 12:49:03 +0000 Subject: ofz#43949 Timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia1691d30e754924314d39d733135614db4c56834 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128768 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- lotuswordpro/source/filter/lwptablelayout.cxx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx index 70a387781394..c3d027e91008 100644 --- a/lotuswordpro/source/filter/lwptablelayout.cxx +++ b/lotuswordpro/source/filter/lwptablelayout.cxx @@ -111,22 +111,24 @@ LwpTableLayout* LwpSuperTableLayout::GetTableLayout() { LwpObjectID *pID = &GetChildTail(); - while(pID && !pID->IsNull()) + o3tl::sorted_vector aSeen; + while (pID && !pID->IsNull()) { + bool bAlreadySeen = !aSeen.insert(pID).second; + if (bAlreadySeen) + throw std::runtime_error("loop in conversion"); + LwpLayout* pLayout = dynamic_cast(pID->obj().get()); if (!pLayout) - { break; - } if (pLayout->GetLayoutType() == LWP_TABLE_LAYOUT) - { return dynamic_cast(pLayout); - } pID = &pLayout->GetPrevious(); } return nullptr; } + /** * @short Get effective heading table layout, the one just before table layout is the only one which is effective * @return LwpTableHeadingLayout* - pointer to table heading layout @@ -135,23 +137,24 @@ LwpTableHeadingLayout* LwpSuperTableLayout::GetTableHeadingLayout() { LwpObjectID *pID = &GetChildTail(); - while(pID && !pID->IsNull()) + o3tl::sorted_vector aSeen; + while (pID && !pID->IsNull()) { + bool bAlreadySeen = !aSeen.insert(pID).second; + if (bAlreadySeen) + throw std::runtime_error("loop in conversion"); + LwpLayout * pLayout = dynamic_cast(pID->obj().get()); if (!pLayout) - { break; - } - if (pLayout->GetLayoutType() == LWP_TABLE_HEADING_LAYOUT) - { return dynamic_cast(pLayout); - } pID = &pLayout->GetPrevious(); } return nullptr; } + /** * @short Register super table layout style */ -- cgit