summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-10-07 09:21:28 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-10-07 14:54:12 +0200
commit21c78b4e94c6cfb9ec38fd4c94091559f8850344 (patch)
treeb17312cb1259d979318db1c8c8aceb1dae63ddbf
parent946b0840a0db5aabfb0d60916abf161d755170f4 (diff)
ofz: Timeout, detect infinite loop
Change-Id: I3234443e2dde9d68b7704fdd3ccf6bdeebef5ee0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123205 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx17
1 files changed, 14 insertions, 3 deletions
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 1bbeb17334a3..5328487e1313 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -1789,11 +1789,22 @@ void WW8FlyPara::ReadFull(sal_uInt8 nOrigSp29, SwWW8ImplReader* pIo)
ww::WordVersion eVer = pIo->GetFib().GetFIBVersion();
WW8FlyPara *pNowStyleApo=nullptr;
sal_uInt16 nColl = pPap->GetIstd();
- ww::sti eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc( static_cast< sal_uInt8 >(nColl) ) : static_cast<ww::sti>(nColl);
- while (eSti != ww::stiNil && sal::static_int_cast<size_t>(nColl) < pIo->m_vColl.size() && nullptr == (pNowStyleApo = pIo->m_vColl[nColl].m_xWWFly.get()))
+
+ o3tl::sorted_vector<sal_uInt16> aSeenStyles;
+ ww::sti eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc(nColl) : static_cast<ww::sti>(nColl);
+ while (eSti != ww::stiNil && static_cast<size_t>(nColl) < pIo->m_vColl.size() && nullptr == (pNowStyleApo = pIo->m_vColl[nColl].m_xWWFly.get()))
{
+ aSeenStyles.insert(nColl);
+
nColl = pIo->m_vColl[nColl].m_nBase;
- eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc( static_cast< sal_uInt8 >(nColl) ) : static_cast<ww::sti>(nColl);
+
+ if (aSeenStyles.find(nColl) != aSeenStyles.end())
+ {
+ SAL_WARN("sw.ww8", "loop in style chain");
+ break;
+ }
+
+ eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc(nColl) : static_cast<ww::sti>(nColl);
}
WW8FlyPara aF(bVer67, pNowStyleApo);